Skip to content

Commit

Permalink
Correct the status description and modify time of evals which are can…
Browse files Browse the repository at this point in the history
…celed
  • Loading branch information
stswidwinski committed May 3, 2023
1 parent 50f0541 commit eaf803c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.CreateTime

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 @@ -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")
}
Expand Down

0 comments on commit eaf803c

Please sign in to comment.