Skip to content

Commit

Permalink
kill taskrunners if all tasks are dead
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 16, 2022
1 parent 464279e commit 859b089
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ func (ar *allocRunner) handleTaskStateUpdates() {
liveRunners := make([]*taskrunner.TaskRunner, 0, trNum)
states := make(map[string]*structs.TaskState, trNum)

allDead := true
for name, tr := range ar.tasks {
taskState := tr.TaskState()
states[name] = taskState
Expand All @@ -529,6 +530,7 @@ func (ar *allocRunner) handleTaskStateUpdates() {
// Capture live task runners in case we need to kill them
if taskState.State != structs.TaskStateDead {
liveRunners = append(liveRunners, tr)
allDead = false
continue
}

Expand All @@ -546,6 +548,10 @@ func (ar *allocRunner) handleTaskStateUpdates() {
}
}

if allDead {
states = ar.killTasks()
}

// if all live runners are sidecars - kill alloc
if killEvent == nil && hasSidecars && !hasNonSidecarTasks(liveRunners) {
killEvent = structs.NewTaskEvent(structs.TaskMainDead)
Expand Down

0 comments on commit 859b089

Please sign in to comment.