diff --git a/client/allocrunnerv2/alloc_runner.go b/client/allocrunnerv2/alloc_runner.go index 56fcf12e3..1cd75eeaf 100644 --- a/client/allocrunnerv2/alloc_runner.go +++ b/client/allocrunnerv2/alloc_runner.go @@ -255,20 +255,20 @@ func (ar *allocRunner) TaskStateUpdated(taskName string, state *structs.TaskStat // If the task failed, we should kill all the other tasks in the task group. if state.Failed { - for _, tr := range otherTaskRunners { - tr.Kill(context.Background(), structs.NewTaskEvent(structs.TaskSiblingFailed).SetFailedSibling(taskName)) - } if len(otherTaskRunners) > 0 { ar.logger.Debug("task failure, destroying all tasks", "failed_task", taskName, "destroying", otherTaskNames) } + for _, tr := range otherTaskRunners { + tr.Kill(context.Background(), structs.NewTaskEvent(structs.TaskSiblingFailed).SetFailedSibling(taskName)) + } } else if leader { + if len(otherTaskRunners) > 0 { + ar.logger.Debug("leader task dead, destroying all tasks", "leader_task", taskName, "destroying", otherTaskNames) + } // If the task was a leader task we should kill all the other tasks. for _, tr := range otherTaskRunners { tr.Kill(context.Background(), structs.NewTaskEvent(structs.TaskLeaderDead)) } - if len(otherTaskRunners) > 0 { - ar.logger.Debug("leader task dead, destroying all tasks", "leader_task", taskName, "destroying", otherTaskNames) - } } }