-
Notifications
You must be signed in to change notification settings - Fork 63
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
[ACM-10865] fine-grain-rbac tech-preview #1401
base: main
Are you sure you want to change the base?
[ACM-10865] fine-grain-rbac tech-preview #1401
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: subbarao-meduri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Left a few comments.
In general, I think we should move all these fine-grained rbac functions outside of the util
package (which is an anti-pattern, by the way) into a properly named package rbac
package.
Also noticed that we log waaaay too much at the info
level. Many of these logs could be at a higher level, like warn or debug.
@@ -50,6 +53,7 @@ var ( | |||
|
|||
managedLabelList = proxyconfig.GetManagedClusterLabelList() | |||
syncLabelList = proxyconfig.GetSyncLabelList() | |||
accessReviewer *rbac.AccessReviewer |
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.
Can we avoid adding yet another global variable in favor of a local variable that is passed around properly? Particularly a global variable that can be nil
is very error prone.
// stubbing to return "empty" i.e all clusters | ||
|
||
query := queryValues.Get(key) | ||
reg := regexp.MustCompile(`([{|,][ ]*)cluster(=|!=|=~|!~)([ ]*)"([^"]+)"`) |
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.
This regex should be moved outside of this function so that it's compiled only once.
modifiedQuery, err := rewrite.InjectLabels(originalQuery, "cluster", clusterList) | ||
if err != nil { | ||
return queryValues | ||
} | ||
|
||
klog.Infof("REQRITE QUERY Modified Query after injecting clusters: \n %v", modifiedQuery) | ||
|
||
modifiedQuery2 := modifiedQuery |
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.
Why the copy?
func createFakeServerWithInvalidJSON(port string, t *testing.T) { | ||
func createFakeServerWithInvalidJSON(port string) { |
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.
This is weird. Often in functions that receive a *testing.T
we put it at the first argument.
go func() { | ||
createFakeServer("3002") | ||
}() |
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.
How is this server ever stopped? Who stops it?
proxy/pkg/util/util_test.go
Outdated
@@ -224,7 +226,11 @@ func TestRewriteQuery(t *testing.T) { | |||
} | |||
|
|||
for _, c := range testCaseList { | |||
output := rewriteQuery(c.urlValue, c.clusterList, c.key) | |||
clusterMap := make(map[string][]string) |
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.
This map can be preallocated to match the size of c.clusterList
.
d7240d7
to
556698d
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@subbarao-meduri: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
556698d
to
9c16d35
Compare
Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
9c16d35
to
24ca2dd
Compare
Forward port fine-rain-rbac dev-preview code into ACM 2.11.