Skip to content

Commit

Permalink
remove container stat dir when no process found in restore
Browse files Browse the repository at this point in the history
Under some abnormal cases, container state dir exist while pid file not.
containerd restore would print this error to log without handling this,
it will set container state to stopped without removing its state dir.

trying to start the container again will cause error:
`mkdir /var/run/docker/libcontainerd/containerd/xxx: file exists`

Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
  • Loading branch information
Deng Guangxing committed May 10, 2017
1 parent 8ef7df5 commit 6feebe9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ func (s *Supervisor) restore() error {
continue
}
processes, err := container.Processes()
if err != nil {
return err
if err != nil || len(processes) == 0 {
logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: container has no process running,removing state directory.")
os.RemoveAll(filepath.Join(s.stateDir, id))
continue
}

ContainersCounter.Inc(1)
Expand Down

0 comments on commit 6feebe9

Please sign in to comment.