Merge pull request #174 from Random-Liu/fix-network-teardown

Do not teardown when network namespace is removed already.
This commit is contained in:
Lantao Liu 2017-08-27 22:56:43 -07:00 committed by GitHub
commit 113964e499

View File

@ -58,8 +58,10 @@ func (c *criContainerdService) StopPodSandbox(ctx context.Context, r *runtime.St
// Teardown network for sandbox.
if sandbox.NetNSPath != "" {
if _, err := os.Stat(sandbox.NetNSPath); err != nil {
if !os.IsNotExist(err) {
return nil, fmt.Errorf("failed to stat network namespace path %s :%v", sandbox.NetNSPath, err)
}
} else {
if teardownErr := c.netPlugin.TearDownPod(ocicni.PodNetwork{
Name: sandbox.Config.GetMetadata().GetName(),
Namespace: sandbox.Config.GetMetadata().GetNamespace(),
@ -69,6 +71,7 @@ func (c *criContainerdService) StopPodSandbox(ctx context.Context, r *runtime.St
}); teardownErr != nil {
return nil, fmt.Errorf("failed to destroy network for sandbox %q: %v", id, teardownErr)
}
}
/*TODO:It is still possible that cri-containerd crashes after we teardown the network, but before we remove the network namespace.
In that case, we'll not be able to remove the sandbox anymore. The chance is slim, but we should be aware of that.
In the future, once TearDownPod is idempotent, this will be fixed.*/