Signed-off-by: milindchawre <milindchawre@gmail.com>
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
const ( |
| 13 | 13 |
backoffMultiplier = 2 |
| 14 | 14 |
defaultTimeout = 100 * time.Millisecond |
| 15 |
+ maxRestartTimeout = 1 * time.Minute |
|
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 | 18 |
// ErrRestartCanceled is returned when the restart manager has been |
| ... | ... |
@@ -70,11 +71,15 @@ func (rm *restartManager) ShouldRestart(exitCode uint32, hasBeenManuallyStopped |
| 70 | 70 |
if executionDuration.Seconds() >= 10 {
|
| 71 | 71 |
rm.timeout = 0 |
| 72 | 72 |
} |
| 73 |
- if rm.timeout == 0 {
|
|
| 73 |
+ switch {
|
|
| 74 |
+ case rm.timeout == 0: |
|
| 74 | 75 |
rm.timeout = defaultTimeout |
| 75 |
- } else {
|
|
| 76 |
+ case rm.timeout < maxRestartTimeout: |
|
| 76 | 77 |
rm.timeout *= backoffMultiplier |
| 77 | 78 |
} |
| 79 |
+ if rm.timeout > maxRestartTimeout {
|
|
| 80 |
+ rm.timeout = maxRestartTimeout |
|
| 81 |
+ } |
|
| 78 | 82 |
|
| 79 | 83 |
var restart bool |
| 80 | 84 |
switch {
|