Merge pull request #181 from thaJeztah/18.09_backport_fix_stopped_restart_containers

[18.09 backport] Fix stopped containers with restart-policy showing as "restarting"
Upstream-commit: 160b62e7a5375d11519e54009b450a4ad20ef8ba
Component: engine
This commit is contained in:
Andrew Hsu
2019-03-28 09:10:59 -07:00
committed by GitHub

View File

@ -85,6 +85,8 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
}
daemon.LogContainerEventWithAttributes(c, "die", attributes)
daemon.Cleanup(c)
daemon.setStateCounter(c)
cpErr := c.CheckpointTo(daemon.containersReplica)
if err == nil && restart {
go func() {
@ -101,6 +103,8 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
if err != nil {
c.Lock()
c.SetStopped(&exitStatus)
daemon.setStateCounter(c)
c.CheckpointTo(daemon.containersReplica)
c.Unlock()
defer daemon.autoRemove(c)
if err != restartmanager.ErrRestartCanceled {
@ -110,8 +114,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
}()
}
daemon.setStateCounter(c)
return c.CheckpointTo(daemon.containersReplica)
return cpErr
}
if execConfig := c.ExecCommands.Get(ei.ProcessID); execConfig != nil {