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) // Stop the container's network namespace (if it has one)
if err := c.runtime.teardownNetNS(c); err != nil { neterr := c.runtime.teardownNetNS(c)
logrus.Errorf("Unable to cleanup network for container %s: %q", c.ID(), err)
// 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 neterr
return c.save()
}
return nil
} }
// reloadNetwork reloads the network for the given container, recreating // 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) // Stop the container's network namespace (if it has one)
if err := c.runtime.teardownNetNS(c); err != nil { neterr := c.runtime.teardownNetNS(c)
logrus.Errorf("Unable to clean up network for container %s: %q", c.ID(), err)
}
c.state.NetNS = "" c.state.NetNS = ""
c.state.NetworkStatus = nil c.state.NetworkStatus = nil
if c.valid { // always save even when there was an error
return c.save() 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 // reloadNetwork reloads the network for the given container, recreating