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

Deployment Status Command Does Not Respect -namespace Wildcard #16792

Merged
merged 7 commits into from Apr 12, 2023

Conversation

Juanadelacuesta
Copy link
Member

@Juanadelacuesta Juanadelacuesta commented Apr 5, 2023

This PR addresses the bug reported here

The deployments Namespace filter did not take into account the namespace wildcard, resulting on an empty response every time it was used in conjunction with a prefix. This PR adds the missing wildcard check as well as filtering by the allowed namespaces according to the ACL token.

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!

Comment on lines +470 to +477
allowableNamespaces, err := allowedNSes(aclObj, store, allow)
if err != nil {
if err == structs.ErrPermissionDenied {
reply.Deployments = make([]*structs.Deployment, 0)
return nil
}
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Not blocking but something we might want to get agreement on with the team and then document in our RPC checklist...

There's a small inconsistency here between the behavior of the first permissions check (on line 458) and this permissions check in the blocking query:

  • If you have no permission to any namespace when you make the query, you get ErrPermissionDenied
  • If you have permissions and make a blocking query, and while you're waiting on the blocking query the permissions are removed, you get an empty list.

I spot-checked some of the other List RPCs and it looks like we're inconsistent with this across the code base; some RPCs have both checks (ex. Eval.List, Job.List) while others only have the second check (ex. Namespaces.ListNamespace, Variables.List).

Copy link
Member

@jrasell jrasell left a comment

Choose a reason for hiding this comment

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

LGTM, minor inline suggestion which is not blocking. The PR will also need a changelog entry, so everyone can bask in the fix!

Something that isn't needed before merge would be to use must for all the new test additions, rather than a mix of must and assert/require.

var deploys []*structs.Deployment
paginator, err := paginator.NewPaginator(iter, tokenizer, nil, args.QueryOptions,
paginator, err := paginator.NewPaginator(iter, tokenizer, filters, args.QueryOptions,
Copy link
Member

Choose a reason for hiding this comment

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

While we are in this area, could we change the name of the paginator variable as it clashes with an import.

@Juanadelacuesta Juanadelacuesta added backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line labels Apr 12, 2023
@Juanadelacuesta Juanadelacuesta merged commit a0dad2e into main Apr 12, 2023
24 of 25 checks passed
@Juanadelacuesta Juanadelacuesta deleted the b-gh-13660 branch April 12, 2023 09:02
Juanadelacuesta added a commit that referenced this pull request Apr 12, 2023
* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs
Juanadelacuesta added a commit that referenced this pull request Apr 12, 2023
* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs
Juanadelacuesta added a commit that referenced this pull request Apr 13, 2023
…ace Wildcard (#16865)

* Deployment Status Command Does Not Respect -namespace Wildcard (#16792)

* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs

* fix: remove extra parameter from upsert job
Juanadelacuesta added a commit that referenced this pull request Apr 13, 2023
* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs
Juanadelacuesta added a commit that referenced this pull request Apr 13, 2023
… (#16866)

* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs
Juanadelacuesta added a commit that referenced this pull request Apr 13, 2023
… (#16876)

* func: add namespace support for list deployment

* func: add wildcard to namespace filter for deployments

* Update deployment_endpoint.go

* style: use must instead of require or asseert

* style: rename paginator to avoid clash with import

* style: add changelog entry

* fix: add missing parameter for upsert jobs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants