Correct the status description and modify time of canceled evals. (#17071)

Fix for #17070. Corrected the status description and modify time of evals which are canceled due to another eval having completed in the meantime.
This commit is contained in:
stswidwinski 2023-05-08 08:50:36 -04:00 committed by GitHub
parent 2fbbac5dd8
commit 9c1c2cb5d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

3
.changelog/17071.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
bug: Corrected status description and modification time for canceled evaluations
```

View File

@ -3160,11 +3160,12 @@ func (s *StateStore) nestedUpsertEval(txn *txn, index uint64, eval *structs.Eval
}
// Go through and update the evals
for _, eval := range blocked {
newEval := eval.Copy()
for _, blockedEval := range blocked {
newEval := blockedEval.Copy()
newEval.Status = structs.EvalStatusCancelled
newEval.StatusDescription = fmt.Sprintf("evaluation %q successful", newEval.ID)
newEval.StatusDescription = fmt.Sprintf("evaluation %q successful", eval.ID)
newEval.ModifyIndex = index
newEval.ModifyTime = eval.ModifyTime
if err := txn.Insert("evals", newEval); err != nil {
return fmt.Errorf("eval insert failed: %v", err)

View File

@ -4176,6 +4176,14 @@ func TestStateStore_UpsertEvals_CancelBlocked(t *testing.T) {
t.Fatalf("bad: %#v %#v", out1, out2)
}
if !strings.Contains(out1.StatusDescription, eval.ID) || !strings.Contains(out2.StatusDescription, eval.ID) {
t.Fatalf("bad status description %#v %#v", out1, out2)
}
if out1.ModifyTime != eval.ModifyTime || out2.ModifyTime != eval.ModifyTime {
t.Fatalf("bad modify time %#v %#v", out1, out2)
}
if watchFired(ws) {
t.Fatalf("bad")
}