Skip to content

Commit 9bd3a7c

Browse files
committedFeb 4, 2017
Adding support for docker max restart time
Signed-off-by: milindchawre <[email protected]>
1 parent d6b1b53 commit 9bd3a7c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎restartmanager/restartmanager.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
const (
1313
backoffMultiplier = 2
1414
defaultTimeout = 100 * time.Millisecond
15+
maxRestartTimeout = 1 * time.Minute
1516
)
1617

1718
// ErrRestartCanceled is returned when the restart manager has been
@@ -70,11 +71,15 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
7071
if executionDuration.Seconds() >= 10 {
7172
rm.timeout = 0
7273
}
73-
if rm.timeout == 0 {
74+
switch {
75+
case rm.timeout == 0:
7476
rm.timeout = defaultTimeout
75-
} else {
77+
case rm.timeout < maxRestartTimeout:
7678
rm.timeout *= backoffMultiplier
7779
}
80+
if rm.timeout > maxRestartTimeout {
81+
rm.timeout = maxRestartTimeout
82+
}
7883

7984
var restart bool
8085
switch {

0 commit comments

Comments
 (0)
Please sign in to comment.