mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
Merge pull request #18254 from Luap99/netns-cleanup
libpod: configureNetNS() tear down on errors
This commit is contained in:
@@ -115,7 +115,7 @@ func (r *Runtime) teardownNetworkBackend(ns string, opts types.NetworkOptions) e
|
||||
// execute the network setup in the rootless net ns
|
||||
err = rootlessNetNS.Do(tearDownPod)
|
||||
if cerr := rootlessNetNS.Cleanup(r); cerr != nil {
|
||||
logrus.WithError(err).Error("failed to clean up rootless netns")
|
||||
logrus.WithError(cerr).Error("failed to clean up rootless netns")
|
||||
}
|
||||
rootlessNetNS.Lock.Unlock()
|
||||
} else {
|
||||
|
||||
@@ -592,6 +592,14 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS string) (status map[strin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
// do not forget to tear down the netns when a later error happened.
|
||||
if rerr != nil {
|
||||
if err := r.teardownNetworkBackend(ctrNS, netOpts); err != nil {
|
||||
logrus.Warnf("failed to teardown network after failed setup: %v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// set up rootless port forwarder when rootless with ports and the network status is empty,
|
||||
// if this is called from network reload the network status will not be empty and we should
|
||||
|
||||
Reference in New Issue
Block a user