diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunner/taskrunner/task_runner.go index cf99d8c378..ac9d7a1c26 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunner/taskrunner/task_runner.go @@ -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.