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 <leijitang@huawei.com>
This commit is contained in:
Lei Jitang 2016-04-14 21:40:20 -04:00
parent 348d902768
commit 494297baf8
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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() {