1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon.cleanupContainer() remove named return variable

It only made the code more difficult to read, adding cognitive overload.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-01-25 12:36:38 +01:00
parent cae1dbee01
commit da277f891a
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -77,7 +77,7 @@ func (daemon *Daemon) rmLink(container *container.Container, name string) error
// cleanupContainer unregisters a container from the daemon, stops stats
// collection and cleanly removes contents and metadata from the filesystem.
func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemove, removeVolume bool) (err error) {
func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemove, removeVolume bool) error {
if container.IsRunning() {
if !forceRemove {
state := container.StateString()
@ -97,7 +97,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
// if stats are currently getting collected.
daemon.statsCollector.StopCollection(container)
if err = daemon.containerStop(container, 3); err != nil {
if err := daemon.containerStop(container, 3); err != nil {
return err
}
@ -116,8 +116,7 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
// When container creation fails and `RWLayer` has not been created yet, we
// do not call `ReleaseRWLayer`
if container.RWLayer != nil {
err := daemon.imageService.ReleaseLayer(container.RWLayer)
if err != nil {
if err := daemon.imageService.ReleaseLayer(container.RWLayer); err != nil {
err = errors.Wrapf(err, "container %s", container.ID)
container.SetRemovalError(err)
return err
@ -126,9 +125,9 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
}
if err := system.EnsureRemoveAll(container.Root); err != nil {
e := errors.Wrapf(err, "unable to remove filesystem for %s", container.ID)
container.SetRemovalError(e)
return e
err = errors.Wrapf(err, "unable to remove filesystem for %s", container.ID)
container.SetRemovalError(err)
return err
}
linkNames := daemon.linkIndex.delete(container)
@ -136,8 +135,8 @@ func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemo
daemon.idIndex.Delete(container.ID)
daemon.containers.Delete(container.ID)
daemon.containersReplica.Delete(container)
if e := daemon.removeMountPoints(container, removeVolume); e != nil {
logrus.Error(e)
if err := daemon.removeMountPoints(container, removeVolume); err != nil {
logrus.Error(err)
}
for _, name := range linkNames {
daemon.releaseName(name)