Merge pull request #41698 from cpuguy83/fix_shutdown_handling
Move container exit state to after cleanup.
This commit is contained in:
commit
264353425a
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…
Add table
Reference in a new issue