run post-run/post-stop task runner hooks

Handle when prestart failed while restoring a task, to prevent
accidentally leaking consul/logmon processes.
This commit is contained in:
Mahmood Ali
2019-07-02 18:37:52 +08:00
parent 380262613d
commit 99802390c1

View File

@@ -408,6 +408,11 @@ func (tr *TaskRunner) MarkFailedDead(reason string) {
SetDisplayMessage(reason).
SetFailsTask()
tr.UpdateState(structs.TaskStateDead, event)
// Run the stop hooks in case task was a restored task that failed prestart
if err := tr.stop(); err != nil {
tr.logger.Error("stop failed while marking task dead", "error", err)
}
}
// Run the TaskRunner. Starts the user's task or reattaches to a restored task.