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

feat: auto respect rbac for discovery/sync #532

Merged
merged 6 commits into from
Aug 11, 2023

Conversation

gdsoumya
Copy link
Member

@gdsoumya gdsoumya commented Jul 6, 2023

This PR implements this proposal. PR enables gitops engine to automatically stop watching for resources that it does not have permission to access without having to manually set resource exclusions.

Signed-off-by: Soumya Ghosh Dastidar <[email protected]>
@codecov
Copy link

codecov bot commented Jul 6, 2023

Codecov Report

Patch coverage: 1.92% and project coverage change: -0.97 ⚠️

Comparison is base (425d65e) 55.63% compared to head (9b1f75b) 54.67%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #532      +/-   ##
==========================================
- Coverage   55.63%   54.67%   -0.97%     
==========================================
  Files          41       41              
  Lines        4553     4635      +82     
==========================================
+ Hits         2533     2534       +1     
- Misses       1825     1905      +80     
- Partials      195      196       +1     
Impacted Files Coverage Δ
pkg/cache/settings.go 38.82% <0.00%> (-4.04%) ⬇️
pkg/cache/cluster.go 49.67% <2.08%> (-5.19%) ⬇️

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

Copy link
Member

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

Initial round of review, and I have some comments and questions.

PTAL.

pkg/cache/cluster.go Outdated Show resolved Hide resolved
pkg/cache/cluster.go Show resolved Hide resolved
pkg/cache/cluster.go Outdated Show resolved Hide resolved
pkg/cache/cluster.go Outdated Show resolved Hide resolved
Comment on lines +835 to +838
clientset, err := kubernetes.NewForConfig(config)
if err != 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.

Instead of creating a new client here for the core API, could we not just reuse the existing dynamic client and then call it something like client.Resource(schema.FromAPIVersionAndKind("authorization.k8s.io/v1", "SelfSubjectAccessReviews").Create() below? Creating a new client imho has some side-effects (i.e. a new client-side rate limiter etc).

If there's a specific reason for using a new client, a comment would be nice as to why.

Copy link
Member Author

Choose a reason for hiding this comment

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

No specific reason, I thought of using the concrete type instead of using dynamic client. Will test out with dynamic client instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tested it with dynamic client and for some reason the request to create the access review resource failed with an unauthorized error. I wasn't able to determine why it was happening but my best guess is the dynamic client needs a namespace for creating the resource, but access review is a cluster scope resource so when I pass "" as the namespace it fails the request.

@gdsoumya gdsoumya force-pushed the feat/respect_rbac branch 4 times, most recently from 05917b9 to 4049709 Compare July 12, 2023 10:04
Signed-off-by: Soumya Ghosh Dastidar <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Jul 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
6.1% 6.1% Duplication

@gdsoumya gdsoumya requested a review from jannfis July 21, 2023 06:11
Copy link
Contributor

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

LGTM!

@alexmt alexmt merged commit 187312f into argoproj:master Aug 11, 2023
5 checks passed
@gdsoumya gdsoumya mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants