Skip to content

Commit

Permalink
[executor] Ensure DESTROY hooks can always terminate safely
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Feb 15, 2021
1 parent ea713d8 commit b0f1548
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions executor/executable/basictaskcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func (t *basicTaskBase) startBasicTask() (err error) {
}()

go func() {
err = t.taskCmd.Wait()
taskCmd := t.taskCmd
err = taskCmd.Wait()
// ^ when this unblocks, the task is done

pendingState := mesos.TASK_FINISHED
Expand All @@ -118,9 +119,13 @@ func (t *basicTaskBase) startBasicTask() (err error) {
pendingState = mesos.TASK_FAILED
}

// Can be -1 if the process was killed
exitCode := t.taskCmd.ProcessState.ExitCode()
processTerminatedOnItsOwn := true
exitCode := -1
processTerminatedOnItsOwn := false
if taskCmd != nil && taskCmd.ProcessState != nil {
// Can be -1 if the process was killed
exitCode = taskCmd.ProcessState.ExitCode()
processTerminatedOnItsOwn = true
}

select {
case pending := <- t.pendingFinalTaskStateCh:
Expand Down

0 comments on commit b0f1548

Please sign in to comment.