Retain task states for post stop tasks at the time of node GC (#18005)

* Retain task states for post stop tasks at the time of node GC
This commit is contained in:
stswidwinski
2023-07-21 13:55:00 -04:00
committed by GitHub
parent 4768c2a455
commit b9a388f5df
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
}