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

fix: implement filtering on cluster List API endpoint #13363

Merged
merged 2 commits into from
May 27, 2023

Conversation

onematchfox
Copy link
Contributor

@onematchfox onematchfox commented Apr 27, 2023

For known security reasons, the Get endpoint on the Clusters service returns a 403 rather than a 404 if a cluster is not found. This means that in order to determine the non-existence of a cluster API, users need to make use of the List endpoint (see comment related to workaround on the behaviour on the applications service).

The application service implements filtering on List allowing the caller to effectively explicitly request a list consisting of a single application which makes this an effective workaround. However, at present, no form of filtering is applied on the cluster List API endpoint despite query parameters being available (see screenshot) below. This means that the same workaround for the clusters service is (extremely) inefficient as all clusters are returned on every call and the caller is left to iterate over all clusters. This PR addresses this issue by implementing filtering on this endpoint using the existing cluster query parameters (in the same manner as the application service.

Screenshot from 2023-04-27 16-40-28

Semi-related to #13000 (see comment here)

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Please see Contribution FAQs if you have questions about your pull-request.

@onematchfox onematchfox force-pushed the feat/cluster-list-filter branch from c995da6 to 3b5f9c3 Compare April 27, 2023 14:51
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch coverage: 85.71% and project coverage change: +0.06 🎉

Comparison is base (67c254e) 49.17% compared to head (ef44e03) 49.24%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13363      +/-   ##
==========================================
+ Coverage   49.17%   49.24%   +0.06%     
==========================================
  Files         248      248              
  Lines       42872    42925      +53     
==========================================
+ Hits        21084    21139      +55     
+ Misses      19687    19680       -7     
- Partials     2101     2106       +5     
Impacted Files Coverage Δ
server/cluster/cluster.go 50.13% <85.71%> (+10.20%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@onematchfox onematchfox requested a review from ishitasequeira May 3, 2023 08:50
Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

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

I tested the PR and the List call does work with the filer.

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

@onematchfox would you mind adding a note to the 2.8 upgrade notes about this? Even though it's fixing something that's obviously broken, it is technically a breaking API change. Good to give folks a heads-up.

@onematchfox onematchfox force-pushed the feat/cluster-list-filter branch from 3eb2f9f to 2f94493 Compare May 7, 2023 02:21
@onematchfox
Copy link
Contributor Author

@onematchfox would you mind adding a note to the 2.8 upgrade notes about this? Even though it's fixing something that's obviously broken, it is technically a breaking API change. Good to give folks a heads-up.

@crenshaw-dev, not 100% sure what upgrade notes you are referring to - perhaps because I'm the first "upgrade note" for 2.8. Anyway, hopefully, what I've done is right.

@onematchfox onematchfox requested a review from crenshaw-dev May 7, 2023 02:21
@onematchfox onematchfox force-pushed the feat/cluster-list-filter branch from 2f94493 to 919eb45 Compare May 16, 2023 10:21
Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>
@onematchfox onematchfox force-pushed the feat/cluster-list-filter branch from 919eb45 to bd97f6f Compare May 24, 2023 07:14
Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>
@onematchfox onematchfox force-pushed the feat/cluster-list-filter branch from bd97f6f to ef44e03 Compare May 24, 2023 07:15
@onematchfox
Copy link
Contributor Author

@crenshaw-dev Just a reminder that this one is ready for final review

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Thanks, @onematchfox!

@crenshaw-dev crenshaw-dev merged commit c3874a2 into argoproj:master May 27, 2023
@onematchfox onematchfox deleted the feat/cluster-list-filter branch June 5, 2023 10:40
yyzxw pushed a commit to yyzxw/argo-cd that referenced this pull request Aug 9, 2023
* feat: implement filtering on cluster list endpoint

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>

* docs: add upgrade notes

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>

---------

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>
tesla59 pushed a commit to tesla59/argo-cd that referenced this pull request Dec 16, 2023
* feat: implement filtering on cluster list endpoint

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>

* docs: add upgrade notes

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>

---------

Signed-off-by: OneMatchFox <878612+onematchfox@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants