-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix ACL bugs in listing allocs across all namespaces #9278
Conversation
return true | ||
} | ||
|
||
return namespaces[alloc.Namespace] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this filter was backwards... it also didn't account for the case where namespaces == nil
, which is what is returned by a short-circuit for management tokens.
the specificity of this method ultimately wasn't very useful.
require.NoError(t, err) | ||
err = state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc}) | ||
require.NoError(t, err) | ||
// two namespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this previously didn't test multiple namespaces, so i expanded it while i was here
@@ -29,6 +29,10 @@ func (a *Alloc) List(args *structs.AllocListRequest, reply *structs.AllocListRes | |||
} | |||
defer metrics.MeasureSince([]string{"nomad", "alloc", "list"}, time.Now()) | |||
|
|||
if args.RequestNamespace() == structs.AllNamespacesSentinel { | |||
return a.listAllNamespaces(args, reply) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this early jump is the same pattern employed for /v1/jobs
and /v1/scaling/policies
:
Lines 1301 to 1303 in 3926317
if args.RequestNamespace() == structs.AllNamespacesSentinel { | |
return j.listAllNamespaces(args, reply) | |
} |
nomad/nomad/scaling_endpoint.go
Lines 31 to 33 in 3926317
if args.RequestNamespace() == structs.AllNamespacesSentinel { | |
return p.listAllNamespaces(args, reply) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. Thanks @DingoEatingFuzz and @cgbaker !
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
resolves #9268
first commit adds a test that multi-namespace queries actually works... as well as a documenting test that ACLs with multi-namespace query didn't work.
second commit fixes the discovered issues, using the multi-namespace pattern employed by
/v1/jobs
and/v1/scaling/policies