From 3bca9472f081988b57910b41074182cdb70ffc4f Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Thu, 19 Jul 2018 10:49:46 -0700 Subject: [PATCH] log before killing tasks --- client/allocrunnerv2/alloc_runner.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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) - } } }