Skip to content

Commit

Permalink
Correct the status description and modify time of canceled evals. (#1…
Browse files Browse the repository at this point in the history
…7071)

Fix for #17070. Corrected the status description and modify time of evals which are canceled due to another eval having completed in the meantime.
  • Loading branch information
stswidwinski authored and tgross committed May 8, 2023
1 parent 3ff9f66 commit d6056a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/17071.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bug: Corrected status description and modification time for canceled evaluations
```
7 changes: 4 additions & 3 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3120,11 +3120,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)
Expand Down
8 changes: 8 additions & 0 deletions nomad/state/state_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4108,6 +4108,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")
}
Expand Down

0 comments on commit d6056a8

Please sign in to comment.