From eaf803c8fe93324a31a41cab0d22ed90e50dec52 Mon Sep 17 00:00:00 2001 From: stswidwinski Date: Wed, 3 May 2023 22:40:12 +0800 Subject: [PATCH 1/3] Correct the status description and modify time of evals which are canceled --- nomad/state/state_store.go | 7 ++++--- nomad/state/state_store_test.go | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 7d1c7d1d2a75..7883c0c38fc3 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -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) diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index 5afa1e61c3f9..4f6f9aeafd2c 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -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") } From ee1b3875ed8bcc2cab8213233c745730aa842153 Mon Sep 17 00:00:00 2001 From: stswidwinski Date: Thu, 4 May 2023 08:55:29 -0400 Subject: [PATCH 2/3] Update nomad/state/state_store.go Ensure modification time of completed and canceled evaluations is the same Co-authored-by: Tim Gross --- nomad/state/state_store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 7883c0c38fc3..cfae8e47a204 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -3165,7 +3165,7 @@ func (s *StateStore) nestedUpsertEval(txn *txn, index uint64, eval *structs.Eval newEval.Status = structs.EvalStatusCancelled newEval.StatusDescription = fmt.Sprintf("evaluation %q successful", eval.ID) newEval.ModifyIndex = index - newEval.ModifyTime = eval.CreateTime + newEval.ModifyTime = eval.ModifyTime if err := txn.Insert("evals", newEval); err != nil { return fmt.Errorf("eval insert failed: %v", err) From fec4a59fd4e299f2626bdd7513e98a8fb4ee20a3 Mon Sep 17 00:00:00 2001 From: stswidwinski Date: Fri, 5 May 2023 23:36:33 +0800 Subject: [PATCH 3/3] Changelog --- .changelog/17071.txt | 3 +++ 1 file changed, 3 insertions(+) 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 +```