|
@@ -76,22 +76,20 @@ func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // stop collection of stats for the container regardless
|
|
|
|
- // if stats are currently getting collected.
|
|
|
|
- daemon.statsCollector.stopCollection(container)
|
|
|
|
-
|
|
|
|
- element := daemon.containers.Get(container.ID)
|
|
|
|
- if element == nil {
|
|
|
|
- return derr.ErrorCodeRmNotFound.WithArgs(container.ID)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Container state RemovalInProgress should be used to avoid races.
|
|
// Container state RemovalInProgress should be used to avoid races.
|
|
if err = container.setRemovalInProgress(); err != nil {
|
|
if err = container.setRemovalInProgress(); err != nil {
|
|
|
|
+ if err == derr.ErrorCodeAlreadyRemoving {
|
|
|
|
+ // do not fail when the removal is in progress started by other request.
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
return derr.ErrorCodeRmState.WithArgs(err)
|
|
return derr.ErrorCodeRmState.WithArgs(err)
|
|
}
|
|
}
|
|
-
|
|
|
|
defer container.resetRemovalInProgress()
|
|
defer container.resetRemovalInProgress()
|
|
|
|
|
|
|
|
+ // stop collection of stats for the container regardless
|
|
|
|
+ // if stats are currently getting collected.
|
|
|
|
+ daemon.statsCollector.stopCollection(container)
|
|
|
|
+
|
|
if err = container.Stop(3); err != nil {
|
|
if err = container.Stop(3); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|