Browse code

Merge pull request #22123 from crosbymichael/restart-canceled

Remove restart canceled error

Brian Goff authored on 2016/04/20 05:28:33
Showing 2 changed files
... ...
@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11 11
 	containerd "github.com/docker/containerd/api/grpc/types"
12
+	"github.com/docker/docker/restartmanager"
12 13
 	"github.com/opencontainers/specs/specs-go"
13 14
 	"golang.org/x/net/context"
14 15
 )
... ...
@@ -148,7 +149,9 @@ func (ctr *container) handleEvent(e *containerd.Event) error {
148 148
 								logrus.Error(err)
149 149
 							}
150 150
 						})
151
-						logrus.Error(err)
151
+						if err != restartmanager.ErrRestartCanceled {
152
+							logrus.Error(err)
153
+						}
152 154
 					} else {
153 155
 						ctr.start()
154 156
 					}
... ...
@@ -1,6 +1,7 @@
1 1
 package restartmanager
2 2
 
3 3
 import (
4
+	"errors"
4 5
 	"fmt"
5 6
 	"sync"
6 7
 	"time"
... ...
@@ -13,6 +14,10 @@ const (
13 13
 	defaultTimeout    = 100 * time.Millisecond
14 14
 )
15 15
 
16
+// ErrRestartCanceled is returned when the restart manager has been
17
+// canceled and will no longer restart the container.
18
+var ErrRestartCanceled = errors.New("restart canceled")
19
+
16 20
 // RestartManager defines object that controls container restarting rules.
17 21
 type RestartManager interface {
18 22
 	Cancel() error
... ...
@@ -54,7 +59,7 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
54 54
 	}()
55 55
 
56 56
 	if rm.canceled {
57
-		return false, nil, fmt.Errorf("restartmanager canceled")
57
+		return false, nil, ErrRestartCanceled
58 58
 	}
59 59
 
60 60
 	if rm.active {
... ...
@@ -95,7 +100,7 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
95 95
 	go func() {
96 96
 		select {
97 97
 		case <-rm.cancel:
98
-			ch <- fmt.Errorf("restartmanager canceled")
98
+			ch <- ErrRestartCanceled
99 99
 			close(ch)
100 100
 		case <-time.After(rm.timeout):
101 101
 			rm.Lock()