Merge pull request #23553 from Luap99/net-cleanup-err

libpod: cleanupNetwork() return error
This commit is contained in:
openshift-merge-bot[bot]
2024-08-09 10:29:37 +00:00
committed by GitHub
2 changed files with 19 additions and 14 deletions

View File

@ -146,15 +146,18 @@ func (c *Container) cleanupNetwork() error {
}
// Stop the container's network namespace (if it has one)
if err := c.runtime.teardownNetNS(c); err != nil {
logrus.Errorf("Unable to cleanup network for container %s: %q", c.ID(), err)
neterr := c.runtime.teardownNetNS(c)
// always save even when there was an error
err = c.save()
if err != nil {
if neterr != nil {
logrus.Errorf("Unable to clean up network for container %s: %q", c.ID(), neterr)
}
return err
}
if c.valid {
return c.save()
}
return nil
return neterr
}
// reloadNetwork reloads the network for the given container, recreating

View File

@ -187,18 +187,20 @@ func (c *Container) cleanupNetwork() error {
}
// Stop the container's network namespace (if it has one)
if err := c.runtime.teardownNetNS(c); err != nil {
logrus.Errorf("Unable to clean up network for container %s: %q", c.ID(), err)
}
neterr := c.runtime.teardownNetNS(c)
c.state.NetNS = ""
c.state.NetworkStatus = nil
if c.valid {
return c.save()
// always save even when there was an error
err = c.save()
if err != nil {
if neterr != nil {
logrus.Errorf("Unable to clean up network for container %s: %q", c.ID(), neterr)
}
return err
}
return nil
return neterr
}
// reloadNetwork reloads the network for the given container, recreating