Skip to content

Commit

Permalink
state: fix eval list by prefix with * namespace (#13551)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 authored Jul 7, 2022
1 parent 52389ff commit d9a0d64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/13551.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
state: Fix listing evaluations from all namespaces
```
3 changes: 2 additions & 1 deletion nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3294,7 +3294,8 @@ func evalNamespaceFilter(namespace string) func(interface{}) bool {
return true
}

return eval.Namespace != namespace
return namespace != structs.AllNamespacesSentinel &&
eval.Namespace != namespace
}
}

Expand Down
4 changes: 4 additions & 0 deletions nomad/state/state_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d9a0d64

Please sign in to comment.