Backport of Retain task states for post stop tasks at the time of node GC into release/1.6.x (#18033)

This pull request was automerged via backport-assistant
This commit is contained in:
hc-github-team-nomad-core 2023-07-21 12:55:29 -05:00 committed by GitHub
parent 95e71a82a4
commit 02c2f1a50f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

3
.changelog/17971.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
client: Fixed a bug where the state of poststop tasks could be corrupted by client gc
```

View File

@ -734,6 +734,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
}