Procházet zdrojové kódy

Adding support for docker max restart time

Signed-off-by: milindchawre <milindchawre@gmail.com>
milindchawre před 8 roky
rodič
revize
9bd3a7c029
1 změnil soubory, kde provedl 7 přidání a 2 odebrání
  1. 7 2
      restartmanager/restartmanager.go

+ 7 - 2
restartmanager/restartmanager.go

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