From d060054c87026284984a5c078c3d1bbab0ac4f6a Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Thu, 14 Apr 2016 21:40:20 -0400 Subject: [PATCH] Don't throw "restartmanager canceled" error for no restart policy container Don't throw "restartmanager canceled" error for no restart policy container and add the container id to the warning message if a container has restart policy and has been canceled. Signed-off-by: Lei Jitang Upstream-commit: 494297baf8f391ce73cdc2e885a335a266261970 Component: engine --- components/engine/libcontainerd/container_linux.go | 2 +- components/engine/restartmanager/restartmanager.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/engine/libcontainerd/container_linux.go b/components/engine/libcontainerd/container_linux.go index ed0ff05ffa..1857874b32 100644 --- a/components/engine/libcontainerd/container_linux.go +++ b/components/engine/libcontainerd/container_linux.go @@ -120,7 +120,7 @@ func (ctr *container) handleEvent(e *containerd.Event) error { if st.State == StateExit && ctr.restartManager != nil { restart, wait, err := ctr.restartManager.ShouldRestart(e.Status, false) if err != nil { - logrus.Error(err) + logrus.Warnf("container %s %v", ctr.containerID, err) } else if restart { st.State = StateRestart ctr.restarting = true diff --git a/components/engine/restartmanager/restartmanager.go b/components/engine/restartmanager/restartmanager.go index 2cf1de684f..38730a9dd9 100644 --- a/components/engine/restartmanager/restartmanager.go +++ b/components/engine/restartmanager/restartmanager.go @@ -42,6 +42,9 @@ func (rm *restartManager) SetPolicy(policy container.RestartPolicy) { } func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped bool) (bool, chan error, error) { + if rm.policy.IsNone() { + return false, nil, nil + } rm.Lock() unlockOnExit := true defer func() {