taskrunner: Return the restart delay correctly

We were incorrectly returning a 0 duration to the taskrunner when
determining when a task should restart. This would cause tasks to be
restarted immediately, ignoring the restart {} stanza in a users
configuration.

This commit causes us to return the restart duration to the task runner
so it may correctly delay further execution.
This commit is contained in:
Danielle Tomlinson
2018-11-20 21:52:23 +01:00
parent a1d5f127e3
commit d73c2f3c8d

View File

@@ -457,7 +457,7 @@ func (tr *TaskRunner) shouldRestart() (bool, time.Duration) {
case structs.TaskRestarting:
tr.logger.Info("restarting task", "reason", reason, "delay", when)
tr.UpdateState(structs.TaskStatePending, structs.NewTaskEvent(structs.TaskRestarting).SetRestartDelay(when).SetRestartReason(reason))
return true, 0
return true, when
default:
tr.logger.Error("restart tracker returned unknown state", "state", state)
return true, when