Skip to content

Commit

Permalink
Only ignore "no such file or directory" error for empty path
Browse files Browse the repository at this point in the history
Signed-off-by: Lantao Liu <lantaol@google.com>
  • Loading branch information
Random-Liu committed Oct 10, 2018
1 parent cc959f7 commit 5ce81a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,16 @@ func (c *libcni) Remove(id string, path string, opts ...NamespaceOpts) error {
return err
}
for _, network := range c.networks {
if err := network.Remove(ns); err != nil && !strings.Contains(err.Error(), "no such file or directory") {
if err := network.Remove(ns); err != nil {
// Based on CNI spec v0.7.0, empty network namespace is allowed to
// do best effort cleanup. However, it is not handled consistently
// right now:
// https://github.com/containernetworking/plugins/issues/210
// TODO(random-liu): Remove the error handling when the issue is
// fixed and the CNI spec v0.6.0 support is deprecated.
if path == "" && strings.Contains(err.Error(), "no such file or directory") {
continue
}
return err
}
}
Expand Down

0 comments on commit 5ce81a6

Please sign in to comment.