diff --git a/.changelog/17071.txt b/.changelog/17071.txt new file mode 100644 index 000000000000..9508299cd628 --- /dev/null +++ b/.changelog/17071.txt @@ -0,0 +1,3 @@ +```release-note:bug +bug: Corrected status description and modification time for canceled evaluations +``` diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index f6bd4e7c9ac4..2e78bb58fe5e 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -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) diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index 0fc48dac13ce..90b61e321a37 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -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") }