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)