Skip to content

Commit

Permalink
network: Drop mounted parameter in call to deleteNetNS
Browse files Browse the repository at this point in the history
All calls to deleteNetNS were passing the "mounted" parameter as
true. So drop this parameter.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
  • Loading branch information
amshinde committed Jun 17, 2018
1 parent f2d9632 commit 0806dcc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (n *cni) remove(sandbox *Sandbox, networkNS NetworkNamespace, netNsCreated
}

if netNsCreated {
return deleteNetNS(networkNS.NetNsPath, true)
return deleteNetNS(networkNS.NetNsPath)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/cnm.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (n *cnm) remove(sandbox *Sandbox, networkNS NetworkNamespace, netNsCreated
}

if netNsCreated {
return deleteNetNS(networkNS.NetNsPath, true)
return deleteNetNS(networkNS.NetNsPath)
}

return nil
Expand Down
16 changes: 6 additions & 10 deletions virtcontainers/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ func doNetNS(netNSPath string, cb func(ns.NetNS) error) error {
return cb(targetNS)
}

func deleteNetNS(netNSPath string, mounted bool) error {
func deleteNetNS(netNSPath string) error {
n, err := ns.GetNS(netNSPath)
if err != nil {
return err
Expand All @@ -1123,15 +1123,11 @@ func deleteNetNS(netNSPath string, mounted bool) error {
return err
}

// This unmount part is supposed to be done in the cni/ns package, but the "mounted"
// flag is not updated when retrieving NetNs handler from GetNS().
if mounted {
if err = unix.Unmount(netNSPath, unix.MNT_DETACH); err != nil {
return fmt.Errorf("Failed to unmount namespace %s: %v", netNSPath, err)
}
if err := os.RemoveAll(netNSPath); err != nil {
return fmt.Errorf("Failed to clean up namespace %s: %v", netNSPath, err)
}
if err = unix.Unmount(netNSPath, unix.MNT_DETACH); err != nil {
return fmt.Errorf("Failed to unmount namespace %s: %v", netNSPath, err)
}
if err := os.RemoveAll(netNSPath); err != nil {
return fmt.Errorf("Failed to clean up namespace %s: %v", netNSPath, err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestCreateDeleteNetNS(t *testing.T) {
t.Fatal(err)
}

err = deleteNetNS(netNSPath, true)
err = deleteNetNS(netNSPath)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 0806dcc

Please sign in to comment.