mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move container exit state to after cleanup.
Before this change, there is no way to know if container (runtime) resources have been cleaned up unless you actually remove the container. This change allows callers of the wait API or the events API to know that all runtime resources for the container are released (e.g. IP addresses). Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
e422445418
commit
e192ce4009
1 changed files with 11 additions and 8 deletions
|
@ -53,6 +53,15 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine
|
|||
}
|
||||
|
||||
restart, wait, err := c.RestartManager().ShouldRestart(ec, daemon.IsShuttingDown() || c.HasBeenManuallyStopped, time.Since(c.StartedAt))
|
||||
|
||||
// cancel healthcheck here, they will be automatically
|
||||
// restarted if/when the container is started again
|
||||
daemon.stopHealthchecks(c)
|
||||
attributes := map[string]string{
|
||||
"exitCode": strconv.Itoa(int(ec)),
|
||||
}
|
||||
daemon.Cleanup(c)
|
||||
|
||||
if err == nil && restart {
|
||||
c.RestartCount++
|
||||
c.SetRestarting(&exitStatus)
|
||||
|
@ -62,17 +71,11 @@ func (daemon *Daemon) handleContainerExit(c *container.Container, e *libcontaine
|
|||
}
|
||||
defer c.Unlock() // needs to be called before autoRemove
|
||||
|
||||
// cancel healthcheck here, they will be automatically
|
||||
// restarted if/when the container is started again
|
||||
daemon.stopHealthchecks(c)
|
||||
attributes := map[string]string{
|
||||
"exitCode": strconv.Itoa(int(ec)),
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(c, "die", attributes)
|
||||
daemon.Cleanup(c)
|
||||
daemon.setStateCounter(c)
|
||||
cpErr := c.CheckpointTo(daemon.containersReplica)
|
||||
|
||||
daemon.LogContainerEventWithAttributes(c, "die", attributes)
|
||||
|
||||
if err == nil && restart {
|
||||
go func() {
|
||||
err := <-wait
|
||||
|
|
Loading…
Reference in a new issue