Skip to content

Commit

Permalink
libnetwork/rootlessnetns: do not cleanup twice in Run()
Browse files Browse the repository at this point in the history
This here just logs unnecessary errors in case there is an error during
the Run() call (podman unshare --rootless-netns). runInner() will
already call cleanup on errors if it created a new netns so we only need
to cleanup when there is no error.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Apr 3, 2024
1 parent 4225302 commit 4eb1803
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions libnetwork/internal/rootlessnetns/netns_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,12 @@ func (n *Netns) Run(lock *lockfile.LockFile, toRun func() error) error {
logrus.Errorf("Failed to decrement ref count: %v", err)
return inErr
}
if count == 0 {
// runInner() already cleans up the netns when it created a new one on errors
// so we only need to do that if there was no error.
if inErr == nil && count == 0 {
err = n.cleanup()
if err != nil {
err = wrapError("cleanup", err)
if inErr == nil {
return err
}
logrus.Errorf("Failed to cleanup rootless netns: %v", err)
return inErr
return wrapError("cleanup", err)
}
}

Expand Down

0 comments on commit 4eb1803

Please sign in to comment.