From 4e71fcacb8d16914bc5672af1c42c998c96999e0 Mon Sep 17 00:00:00 2001 From: Wentao Zhang Date: Wed, 28 Jun 2017 04:14:58 +0800 Subject: [PATCH] Set unpasued state when receiving 'stateExit' event Description: 1. start a container with restart=always. `docker run -d --restart=always ubuntu sleep 3` 2. container init process exits. 3. use `docker pause ` to pause this container. if the pause action is before cgroup data is removed and after the init process died. `Pause` operation will success to write cgroup data, but actually do not freeze any process. And then docker received pause event and stateExit event from containerd, the docker state will be Running(paused), but the container is free running. Then we can not remove it, stop it , pause it and unpause it. Signed-off-by: Wentao Zhang (cherry picked from commit fe1b4cfba6320793373c5397641d743d9fe94cf8) Signed-off-by: Andrew Hsu --- components/engine/container/state.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/engine/container/state.go b/components/engine/container/state.go index e99fe008bb..2f970131ca 100644 --- a/components/engine/container/state.go +++ b/components/engine/container/state.go @@ -278,6 +278,7 @@ func (s *State) SetRunning(pid int, initial bool) { s.ErrorMsg = "" s.Running = true s.Restarting = false + s.Paused = false s.ExitCodeValue = 0 s.Pid = pid if initial { @@ -304,6 +305,7 @@ func (s *State) SetRestarting(exitStatus *ExitStatus) { // all the checks in docker around rm/stop/etc s.Running = true s.Restarting = true + s.Paused = false s.Pid = 0 s.FinishedAt = time.Now().UTC() s.setFromExitStatus(exitStatus)