mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
libpod: cleanupNetwork() return error
Return the error not just log as the caller can then decide to log this and exit > 0. I also removed the c.valid check as I do not see what the purpose of this would be. c.valid is only false when the ctr was removed but then we should never get there as Cleanup() will not work on a container in removing state. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user