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