From 53670de7bcbaae03c28a7d4214182eeea82e492f Mon Sep 17 00:00:00 2001 From: stswidwinski Date: Mon, 8 May 2023 08:50:36 -0400 Subject: [PATCH] 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. --- .changelog/17071.txt | 3 +++ nomad/state/state_store.go | 7 ++++--- nomad/state/state_store_test.go | 8 ++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .changelog/17071.txt 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 c941d8815c45..7c71e455073d 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -3119,11 +3119,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 167f736cca50..805a47ecd1ee 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -4070,6 +4070,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") }