mirror of https://github.com/containers/podman.git
Handle more states during refresh
We were preserving ContainerStateExited, which is better than nothing, but definitely not correct. A container that ran at any point during the last boot should be moved to Exited state to preserve the fact that they were run at least one. This means we have to convert Running, Stopped, Stopping, Paused containers to exited as well. Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
parent
9983e87440
commit
3cf2f8ccf4
|
@ -622,7 +622,19 @@ func resetContainerState(state *ContainerState) {
|
|||
state.ConmonPID = 0
|
||||
state.Mountpoint = ""
|
||||
state.Mounted = false
|
||||
if state.State != define.ContainerStateExited {
|
||||
// Reset state.
|
||||
// Almost all states are reset to either Configured or Exited,
|
||||
// except ContainerStateRemoving which is preserved.
|
||||
switch state.State {
|
||||
case define.ContainerStateStopped, define.ContainerStateExited, define.ContainerStateStopping, define.ContainerStateRunning, define.ContainerStatePaused:
|
||||
// All containers that ran at any point during the last boot
|
||||
// must be placed in the Exited state.
|
||||
state.State = define.ContainerStateExited
|
||||
case define.ContainerStateConfigured, define.ContainerStateCreated:
|
||||
state.State = define.ContainerStateConfigured
|
||||
case define.ContainerStateUnknown:
|
||||
// Something really strange must have happened to get us here.
|
||||
// Reset to configured, maybe the reboot cleared things up?
|
||||
state.State = define.ContainerStateConfigured
|
||||
}
|
||||
state.ExecSessions = make(map[string]*ExecSession)
|
||||
|
|
|
@ -861,7 +861,7 @@ func (r *Runtime) refresh(ctx context.Context, alivePath string) error {
|
|||
}
|
||||
// This is the only place it's safe to use ctr.state.State unlocked
|
||||
// We're holding the alive lock, guaranteed to be the only Libpod on the system right now.
|
||||
if ctr.AutoRemove() && ctr.state.State == define.ContainerStateExited {
|
||||
if (ctr.AutoRemove() && ctr.state.State == define.ContainerStateExited) || ctr.state.State == define.ContainerStateRemoving {
|
||||
opts := ctrRmOpts{
|
||||
// Don't force-remove, we're supposed to be fresh off a reboot
|
||||
// If we have to force something is seriously wrong
|
||||
|
|
Loading…
Reference in New Issue