-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Adding NamespacedRules and handling to GR/GRB #43018
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
Adding NamespacedRules and handling to GR/GRB #43018
Conversation
65f7cc0 to
4849f6b
Compare
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.
I added this test to get 100% code coverage of enqueue.go. I didn't make or modify this function
4849f6b to
c43f703
Compare
|
Integration tests are in progress, opening for review to get feedback on functionality. |
pjbgf
left a comment
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.
two small nits:
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
MbolotSuse
left a comment
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.
Couple of standout issues:
- We need to use
name.SafeConcatNameon the label values - The purge methods should delete roles/bindings in the same namespace that claim ownership by a GR/GRB but aren't actually owned by that GR/GRB
- We can't update the roleRef on a binding, so you need to delete/create for the binding case instead of update
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
|
Newest commit adds the following small reworks:
Large rework:
|
b7363dc to
6f7ee6c
Compare
pjbgf
left a comment
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.
Pointed a few minor nits regarding clarity - feel free to ignore.
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
6f7ee6c to
fc8f0c0
Compare
MbolotSuse
left a comment
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.
Couple of comments on missing uses of safeConcatName, as well as some efficiency improvements.
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
tomleb
left a comment
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.
Some comments
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler_test.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler_test.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
|
New commit changes:
|
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrole_handler.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
eb0fb87 to
006f500
Compare
MbolotSuse
left a comment
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.
A couple of nits, but nothing that I think needs to be fixed for this to go in. I'm ok to approve the PR once the CI passes.
pkg/controllers/management/auth/globalroles/globalrole_handler_test.go
Outdated
Show resolved
Hide resolved
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.
Nit: I highly recommend not creating tests cases like this which rely on call order to function. This highly couples your test case to the internal implementation of the underlying code, and can create flaky tests which fail when a specific order occurs.
In this case, I would recommend pre-computing the name of each role that might be retrieved, and then return a specific response for the specific roles which are being called.
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.
So in this specific test case I could get rid of the counter since I'm trying to get into the error path. However, I kept a similar pattern for the test at line 224. I've added more comments to explain the reason, and changed the counter to be modified based on when Create gets called, not just on consecutive Get calls.
I considered removing the test at 224, but I think it's important functionality to test. The difficulty is that the Get function gets called with the same input twice, but the expected behaviour changes depending on when it happens. I personally think modifying the counter to indicate before and after Create makes it less flaky, but if you feel it shouldn't exist I won't argue much.
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
pkg/controllers/management/auth/globalroles/globalrolebinding_handler_test.go
Outdated
Show resolved
Hide resolved
tomleb
left a comment
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.
No changes since last approval so LGTM. Just added a nit.
3284ace to
81b1df3
Compare
|
Rebased and pointed to release/v2.9 |
MbolotSuse
left a comment
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.
LGTM - don't see any issue due to rebase changes.
Issue: #42215
New Feature
Adds
NamespacedRulesto the GlobalRole field. Details of the field can be found in the issue, but in summation:The work is split in the following commits:
Testing
Engineering Testing
Manual Testing
Automated Testing
Summary: Unit tests for all new code and integration tests (TODO)
QA Testing Considerations
Regressions Considerations
This is a new field, so there shouldn't be any regressions. While the update/create functions for GR/GRBs got modified, the new check only occurs when the field is populated.
Existing / newly added automated tests that provide evidence there are no regressions:
Security Considerations
Need a security assessment to ensure this doesn't introduce CVEs