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

Adding support for docker max restart time

Signed-off-by: milindchawre <milindchawre@gmail.com>
This commit is contained in:
milindchawre 2017-02-02 18:19:17 +00:00
parent d6b1b532a1
commit 9bd3a7c029

View file

@ -12,6 +12,7 @@ import (
const ( const (
backoffMultiplier = 2 backoffMultiplier = 2
defaultTimeout = 100 * time.Millisecond defaultTimeout = 100 * time.Millisecond
maxRestartTimeout = 1 * time.Minute
) )
// ErrRestartCanceled is returned when the restart manager has been // ErrRestartCanceled is returned when the restart manager has been
@ -70,11 +71,15 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped
if executionDuration.Seconds() >= 10 { if executionDuration.Seconds() >= 10 {
rm.timeout = 0 rm.timeout = 0
} }
if rm.timeout == 0 { switch {
case rm.timeout == 0:
rm.timeout = defaultTimeout rm.timeout = defaultTimeout
} else { case rm.timeout < maxRestartTimeout:
rm.timeout *= backoffMultiplier rm.timeout *= backoffMultiplier
} }
if rm.timeout > maxRestartTimeout {
rm.timeout = maxRestartTimeout
}
var restart bool var restart bool
switch { switch {