From 85908415f94f899810619d7bcb7a09a99c15c85e Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 7 Jul 2022 14:21:51 -0400 Subject: [PATCH] state: fix eval list by prefix with * namespace (#13551) --- .changelog/13551.txt | 3 +++ nomad/state/state_store.go | 3 ++- nomad/state/state_store_test.go | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changelog/13551.txt diff --git a/.changelog/13551.txt b/.changelog/13551.txt new file mode 100644 index 000000000..e31859a70 --- /dev/null +++ b/.changelog/13551.txt @@ -0,0 +1,3 @@ +```release-note:bug +state: Fix listing evaluations from all namespaces +``` diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 661586f52..6c11a260a 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -3294,7 +3294,8 @@ func evalNamespaceFilter(namespace string) func(interface{}) bool { return true } - return eval.Namespace != namespace + return namespace != structs.AllNamespacesSentinel && + eval.Namespace != namespace } } diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index c6743dd4f..28edefcc2 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -4636,11 +4636,15 @@ func TestStateStore_EvalsByIDPrefix_Namespaces(t *testing.T) { require.NoError(t, err) iter2, err := state.EvalsByIDPrefix(ws, ns2.Name, sharedPrefix, SortDefault) require.NoError(t, err) + iter3, err := state.EvalsByIDPrefix(ws, structs.AllNamespacesSentinel, sharedPrefix, SortDefault) + require.NoError(t, err) evalsNs1 := gatherEvals(iter1) evalsNs2 := gatherEvals(iter2) + evalsNs3 := gatherEvals(iter3) require.Len(t, evalsNs1, 1) require.Len(t, evalsNs2, 1) + require.Len(t, evalsNs3, 2) iter1, err = state.EvalsByIDPrefix(ws, ns1.Name, eval1.ID[:8], SortDefault) require.NoError(t, err)