Skip to content

Commit

Permalink
Backport of Retain task states for post stop tasks at the time of nod…
Browse files Browse the repository at this point in the history
…e GC into release/1.5.x (#18032)

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core authored Jul 21, 2023
1 parent dd044f2 commit 7a7d93a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/17971.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
client: Fixed a bug where the state of poststop tasks could be corrupted by client gc
```
13 changes: 13 additions & 0 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,19 @@ func (ar *allocRunner) killTasks() map[string]*structs.TaskState {
}
wg.Wait()

// Perform no action on post stop tasks, but retain their states if they exist. This
// commonly happens at the time of alloc GC from the client node.
for name, tr := range ar.tasks {
if !tr.IsPoststopTask() {
continue
}

state := tr.TaskState()
if state != nil {
states[name] = state
}
}

return states
}

Expand Down

0 comments on commit 7a7d93a

Please sign in to comment.