sandbox_stop: close/remove the netns _after_ stopping the containers

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2018-02-22 17:24:57 +01:00
parent 69257aa85c
commit 0fe2aa6e2f
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9

View file

@ -49,13 +49,6 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
return resp, nil return resp, nil
} }
// Clean up sandbox networking and close its network namespace.
hostNetwork := sb.NetNsPath() == ""
s.networkStop(hostNetwork, sb)
if err := sb.NetNsRemove(); err != nil {
return nil, err
}
podInfraContainer := sb.InfraContainer() podInfraContainer := sb.InfraContainer()
containers := sb.Containers().List() containers := sb.Containers().List()
containers = append(containers, podInfraContainer) containers = append(containers, podInfraContainer)
@ -77,6 +70,13 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
s.ContainerStateToDisk(c) s.ContainerStateToDisk(c)
} }
// Clean up sandbox networking and close its network namespace.
hostNetwork := sb.NetNsPath() == ""
s.networkStop(hostNetwork, sb)
if err := sb.NetNsRemove(); err != nil {
return nil, err
}
if err := label.ReleaseLabel(sb.ProcessLabel()); err != nil { if err := label.ReleaseLabel(sb.ProcessLabel()); err != nil {
return nil, err return nil, err
} }
@ -97,6 +97,7 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
} }
} }
} }
if err := s.StorageRuntimeServer().StopContainer(sb.ID()); err != nil && errors.Cause(err) != storage.ErrContainerUnknown { if err := s.StorageRuntimeServer().StopContainer(sb.ID()); err != nil && errors.Cause(err) != storage.ErrContainerUnknown {
logrus.Warnf("failed to stop sandbox container in pod sandbox %s: %v", sb.ID(), err) logrus.Warnf("failed to stop sandbox container in pod sandbox %s: %v", sb.ID(), err)
} }