Do not remove sandbox when netns is not closed.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-11-21 01:22:19 +00:00
parent 74df3cc146
commit 76268ea242
3 changed files with 70 additions and 2 deletions

View File

@@ -107,6 +107,7 @@ func (n *NetNS) Remove() error {
if err := os.RemoveAll(path); err != nil {
return fmt.Errorf("failed to remove netns: %v", err)
}
n.restored = false
}
return nil
}
@@ -115,7 +116,7 @@ func (n *NetNS) Remove() error {
func (n *NetNS) Closed() bool {
n.Lock()
defer n.Unlock()
return n.closed
return n.closed && !n.restored
}
// GetPath returns network namespace path for sandbox container