Skip to content
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

Backport #13530 to 1.2.x #13552

Merged
merged 2 commits into from
Jul 13, 2022
Merged

Backport #13530 to 1.2.x #13552

merged 2 commits into from
Jul 13, 2022

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Jul 4, 2022

Backport the API portion of #13530 to release/1.2.x. Wildcard namespace list support for the eval endpoint was added in 1.2.4, so this doesn't have to be backported to 1.1.x.

Comment on lines +447 to +436
nsAllowed := allowableNamespaces == nil ||
allowableNamespaces[eval.Namespace]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 1.3.x this check is done using the paginator.NamespaceFilter, which doesn't exist in 1.2.x.

Instead of modifying args.ShouldBeFiltered I thought it would be better to make the verification here to keep ShouldBeFiltered the same in release/1.2.x and release/1.3.x.

@lgfa29 lgfa29 requested review from tgross and shoenig July 4, 2022 19:15
Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

iter = memdb.NewFilterIterator(iter, func(raw interface{}) bool {
if eval := raw.(*structs.Evaluation); eval != nil {
return args.ShouldBeFiltered(eval)
// check if user has permission to all namespaces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I think this comment is being copied from elsewhere, but "has permission to all namespaces" seems misleading when what we're really getting is the set of namespace we have permission to.

Comment on lines 411 to 413
allow = func(string) bool {
return true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an example of "the right code looks wrong", because this means we've already passed the ACL check so we don't need to filter below. Maybe leave a comment for it?

Suggested change
allow = func(string) bool {
return true
}
allow = func(string) bool {
return true // we've already passed the only ACL check
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this whole pattern has been copied around in a few places; it'd probably be worth refactoring in some way. At the least, this function could be something like,

AcceptedByACLs = func(string) bool {return true}

so you'd instead have clarity in returning like

default:
  return AcceptedByACLs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In rewriting this I ended up doing a larger refactoring to push most of this logic into the acl package.

#13606 is the main refactoring.
#13608 applies the changes to the existing job and alloc list endpoints.
#13530 applies the changes to the evals list endpoint to fix a bug.

I will redo this eval list bug backport once #13606 is merged into releases/1.2.x.

@lgfa29 lgfa29 mentioned this pull request Jul 5, 2022
4 tasks
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lgfa29 lgfa29 closed this Jul 6, 2022
lgfa29 added 2 commits July 6, 2022 16:19
Apply the same verification process as in job, allocs and scaling
policy list endpoints to handle the eval list when using an ACL token
with limited namespace support but querying using the `*` wildcard
namespace.
@lgfa29 lgfa29 reopened this Jul 6, 2022
@lgfa29 lgfa29 force-pushed the backport-1.2.x-13530 branch from a2c6d99 to 4cffad8 Compare July 6, 2022 20:22
@lgfa29 lgfa29 merged commit acc8689 into release/1.2.x Jul 13, 2022
@lgfa29 lgfa29 deleted the backport-1.2.x-13530 branch July 13, 2022 18:17
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants