1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove restart canceled error

It should not be an error to call a common option to cancel restarts.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-04-18 11:48:28 -07:00
parent a4030787f5
commit fc2e2234c6
2 changed files with 11 additions and 3 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
containerd "github.com/docker/containerd/api/grpc/types" containerd "github.com/docker/containerd/api/grpc/types"
"github.com/docker/docker/restartmanager"
"github.com/opencontainers/specs/specs-go" "github.com/opencontainers/specs/specs-go"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -135,7 +136,9 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
logrus.Error(err) logrus.Error(err)
} }
}) })
logrus.Error(err) if err != restartmanager.ErrRestartCanceled {
logrus.Error(err)
}
} else { } else {
ctr.start() ctr.start()
} }

View file

@ -1,6 +1,7 @@
package restartmanager package restartmanager
import ( import (
"errors"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -13,6 +14,10 @@ const (
defaultTimeout = 100 * time.Millisecond defaultTimeout = 100 * time.Millisecond
) )
// ErrRestartCanceled is returned when the restart manager has been
// canceled and will no longer restart the container.
var ErrRestartCanceled = errors.New("restart canceled")
// RestartManager defines object that controls container restarting rules. // RestartManager defines object that controls container restarting rules.
type RestartManager interface { type RestartManager interface {
Cancel() error Cancel() error
@ -54,7 +59,7 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
}() }()
if rm.canceled { if rm.canceled {
return false, nil, fmt.Errorf("restartmanager canceled") return false, nil, ErrRestartCanceled
} }
if rm.active { if rm.active {
@ -95,7 +100,7 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
go func() { go func() {
select { select {
case <-rm.cancel: case <-rm.cancel:
ch <- fmt.Errorf("restartmanager canceled") ch <- ErrRestartCanceled
close(ch) close(ch)
case <-time.After(rm.timeout): case <-time.After(rm.timeout):
rm.Lock() rm.Lock()