if policy mode is delay, do not fail for multiple startup failures, delay instead

This commit is contained in:
Cameron Davison 2016-07-10 16:34:07 -05:00
parent e2909db9ef
commit dd314ea06e

View file

@ -132,9 +132,15 @@ func (r *RestartTracker) handleStartError() (string, time.Duration) {
}
if r.count > r.policy.Attempts {
r.reason = fmt.Sprintf("Exceeded allowed attempts %d in interval %v",
r.policy.Attempts, r.policy.Interval)
return structs.TaskNotRestarting, 0
if r.policy.Mode == structs.RestartPolicyModeFail {
r.reason = fmt.Sprintf(
`Exceeded allowed atttempts %d in interval %v and mode is "fail"`,
r.policy.Attempts, r.policy.Interval)
return structs.TaskNotRestarting, 0
} else {
r.reason = ReasonDelay
return structs.TaskRestarting, r.getDelay()
}
}
r.reason = ReasonWithinPolicy