state: fix eval list by prefix with * namespace (#13551)

This commit is contained in:
Luiz Aoqui 2022-07-07 14:21:51 -04:00 committed by GitHub
parent 03433dd8af
commit 85908415f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

3
.changelog/13551.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
state: Fix listing evaluations from all namespaces
```

View File

@ -3294,7 +3294,8 @@ func evalNamespaceFilter(namespace string) func(interface{}) bool {
return true
}
return eval.Namespace != namespace
return namespace != structs.AllNamespacesSentinel &&
eval.Namespace != namespace
}
}

View File

@ -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)