Merge pull request #236 from runcom/check-netns-on-stop
server: check netns path on pod stop
This commit is contained in:
commit
8547c0dbd9
1 changed files with 8 additions and 3 deletions
|
@ -2,6 +2,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
@ -24,9 +25,13 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat(netnsPath); err == nil {
|
||||||
if err := s.netPlugin.TearDownPod(netnsPath, podNamespace, sb.id, podInfraContainer.Name()); err != nil {
|
if err2 := s.netPlugin.TearDownPod(netnsPath, podNamespace, sb.id, podInfraContainer.Name()); err2 != nil {
|
||||||
return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v",
|
return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v",
|
||||||
|
podInfraContainer.Name(), sb.id, err2)
|
||||||
|
}
|
||||||
|
} else if !os.IsNotExist(err) { // it's ok for netnsPath to *not* exist
|
||||||
|
return nil, fmt.Errorf("failed to stat netns path for container %s in sandbox %s before tearing down the network: %v",
|
||||||
podInfraContainer.Name(), sb.id, err)
|
podInfraContainer.Name(), sb.id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue