Merge pull request #98 from Random-Liu/not-teardown-network-for-hostnetwork

Do not teardown network namespace when using host network.
This commit is contained in:
Lantao Liu 2017-06-28 19:53:39 -07:00 committed by GitHub
commit a2c4cc206e

View File

@ -68,9 +68,11 @@ func (c *criContainerdService) StopPodSandbox(ctx context.Context, r *runtime.St
// Teardown network for sandbox. // Teardown network for sandbox.
_, err = c.os.Stat(sandbox.NetNS) _, err = c.os.Stat(sandbox.NetNS)
if err == nil { if err == nil {
if teardownErr := c.netPlugin.TearDownPod(sandbox.NetNS, sandbox.Config.GetMetadata().GetNamespace(), if !sandbox.Config.GetLinux().GetSecurityContext().GetNamespaceOptions().GetHostNetwork() {
sandbox.Config.GetMetadata().GetName(), id); teardownErr != nil { if teardownErr := c.netPlugin.TearDownPod(sandbox.NetNS, sandbox.Config.GetMetadata().GetNamespace(),
return nil, fmt.Errorf("failed to destroy network for sandbox %q: %v", id, teardownErr) sandbox.Config.GetMetadata().GetName(), id); teardownErr != nil {
return nil, fmt.Errorf("failed to destroy network for sandbox %q: %v", id, teardownErr)
}
} }
} else if !os.IsNotExist(err) { // It's ok for sandbox.NetNS to *not* exist } else if !os.IsNotExist(err) { // It's ok for sandbox.NetNS to *not* exist
return nil, fmt.Errorf("failed to stat netns path for sandbox %q before tearing down the network: %v", id, err) return nil, fmt.Errorf("failed to stat netns path for sandbox %q before tearing down the network: %v", id, err)