From 50fc6aee462d1f9e364981f8bd95ec8d9b7f00f7 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 21 Apr 2016 13:58:21 -0700 Subject: [PATCH] Fix config cleanup on canceling restartmanager Signed-off-by: Tonis Tiigi Upstream-commit: 7bf07737b90f087271b5a9a3a1c8d262c154554f Component: engine --- components/engine/libcontainerd/container_linux.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/engine/libcontainerd/container_linux.go b/components/engine/libcontainerd/container_linux.go index b844480a74..0eeef6874c 100644 --- a/components/engine/libcontainerd/container_linux.go +++ b/components/engine/libcontainerd/container_linux.go @@ -23,6 +23,9 @@ type container struct { } func (ctr *container) clean() error { + if os.Getenv("LIBCONTAINERD_NOCLEAN") == "1" { + return nil + } if _, err := os.Lstat(ctr.dir); err != nil { if os.IsNotExist(err) { return nil @@ -141,9 +144,12 @@ func (ctr *container) handleEvent(e *containerd.Event) error { ctr.client.deleteContainer(e.Id) go func() { err := <-wait + ctr.client.lock(ctr.containerID) + defer ctr.client.unlock(ctr.containerID) ctr.restarting = false if err != nil { st.State = StateExit + ctr.clean() ctr.client.q.append(e.Id, func() { if err := ctr.client.backend.StateChanged(e.Id, st); err != nil { logrus.Error(err) @@ -163,9 +169,7 @@ func (ctr *container) handleEvent(e *containerd.Event) error { // We need to do so here in case the Message Handler decides to restart it. switch st.State { case StateExit: - if os.Getenv("LIBCONTAINERD_NOCLEAN") != "1" { - ctr.clean() - } + ctr.clean() ctr.client.deleteContainer(e.Id) case StateExitProcess: ctr.cleanProcess(st.ProcessID)