From 46dc2b4347f54aa66cf37f1f6b41a40070da7966 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 6 Dec 2016 13:17:54 +0100 Subject: [PATCH] server: check netns path on pod stop Signed-off-by: Antonio Murdaca --- server/sandbox_stop.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/sandbox_stop.go b/server/sandbox_stop.go index 42dac4ca..39253681 100644 --- a/server/sandbox_stop.go +++ b/server/sandbox_stop.go @@ -2,6 +2,7 @@ package server import ( "fmt" + "os" "github.com/Sirupsen/logrus" "github.com/kubernetes-incubator/cri-o/oci" @@ -24,9 +25,13 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque if err != nil { return nil, err } - - if err := s.netPlugin.TearDownPod(netnsPath, podNamespace, sb.id, podInfraContainer.Name()); err != nil { - return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v", + if _, err := os.Stat(netnsPath); 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", + 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) }