Browse code

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 <id>` 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 <zhangwentao234@huawei.com>

Wentao Zhang authored on 2017/06/28 05:14:58
Showing 1 changed files
... ...
@@ -278,6 +278,7 @@ func (s *State) SetRunning(pid int, initial bool) {
278 278
 	s.ErrorMsg = ""
279 279
 	s.Running = true
280 280
 	s.Restarting = false
281
+	s.Paused = false
281 282
 	s.ExitCodeValue = 0
282 283
 	s.Pid = pid
283 284
 	if initial {
... ...
@@ -304,6 +305,7 @@ func (s *State) SetRestarting(exitStatus *ExitStatus) {
304 304
 	// all the checks in docker around rm/stop/etc
305 305
 	s.Running = true
306 306
 	s.Restarting = true
307
+	s.Paused = false
307 308
 	s.Pid = 0
308 309
 	s.FinishedAt = time.Now().UTC()
309 310
 	s.setFromExitStatus(exitStatus)