Do not teardown when network namespace is removed already.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
8fd54d2f2d
commit
fda30c3ad2
@ -58,16 +58,19 @@ func (c *criContainerdService) StopPodSandbox(ctx context.Context, r *runtime.St
|
|||||||
// Teardown network for sandbox.
|
// Teardown network for sandbox.
|
||||||
if sandbox.NetNSPath != "" {
|
if sandbox.NetNSPath != "" {
|
||||||
if _, err := os.Stat(sandbox.NetNSPath); err != nil {
|
if _, err := os.Stat(sandbox.NetNSPath); err != nil {
|
||||||
return nil, fmt.Errorf("failed to stat network namespace path %s :%v", sandbox.NetNSPath, err)
|
if !os.IsNotExist(err) {
|
||||||
}
|
return nil, fmt.Errorf("failed to stat network namespace path %s :%v", sandbox.NetNSPath, err)
|
||||||
if teardownErr := c.netPlugin.TearDownPod(ocicni.PodNetwork{
|
}
|
||||||
Name: sandbox.Config.GetMetadata().GetName(),
|
} else {
|
||||||
Namespace: sandbox.Config.GetMetadata().GetNamespace(),
|
if teardownErr := c.netPlugin.TearDownPod(ocicni.PodNetwork{
|
||||||
ID: id,
|
Name: sandbox.Config.GetMetadata().GetName(),
|
||||||
NetNS: sandbox.NetNSPath,
|
Namespace: sandbox.Config.GetMetadata().GetNamespace(),
|
||||||
PortMappings: toCNIPortMappings(sandbox.Config.GetPortMappings()),
|
ID: id,
|
||||||
}); teardownErr != nil {
|
NetNS: sandbox.NetNSPath,
|
||||||
return nil, fmt.Errorf("failed to destroy network for sandbox %q: %v", id, teardownErr)
|
PortMappings: toCNIPortMappings(sandbox.Config.GetPortMappings()),
|
||||||
|
}); 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.
|
/*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 that case, we'll not be able to remove the sandbox anymore. The chance is slim, but we should be aware of that.
|
||||||
|
Loading…
Reference in New Issue
Block a user