Skip to content

Commit

Permalink
Fix race in CNI namespaces.
Browse files Browse the repository at this point in the history
Signed-off-by: Vlad A. Ionescu <vladaionescu@users.noreply.github.com>
  • Loading branch information
vladaionescu committed Nov 2, 2020
1 parent 2b6cccb commit 39fd96d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util/network/cniprovider/createns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func createNetNS(c *cniProvider, id string) (string, error) {
errno = syscall.Errno(ws.ExitStatus())
if errno != 0 {
deleteNetNS(p)
return "", errors.Wrap(errno, "failed to mount")
return "", errors.Wrapf(errno, "failed to mount %s (pid=%d)", p, pid)
}
return p, nil
}
Expand All @@ -91,8 +91,8 @@ func unmountNetNS(nativeID string) error {
}

func deleteNetNS(nativeID string) error {
if err := os.RemoveAll(filepath.Dir(nativeID)); err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrap(err, "error removing network namespace")
if err := os.RemoveAll(nativeID); err != nil && !errors.Is(err, os.ErrNotExist) {
return errors.Wrapf(err, "error removing network namespace %s", nativeID)
}
return nil
}

0 comments on commit 39fd96d

Please sign in to comment.