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

[ACM-10865] fine-grain-rbac tech-preview #1401

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

subbarao-meduri
Copy link
Collaborator

Forward port fine-rain-rbac dev-preview code into ACM 2.11.

Copy link

openshift-ci bot commented Apr 10, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@douglascamata douglascamata left a 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
Copy link
Contributor

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.

proxy/pkg/util/util.go Outdated Show resolved Hide resolved
proxy/pkg/util/util.go Outdated Show resolved Hide resolved
// stubbing to return "empty" i.e all clusters

query := queryValues.Get(key)
reg := regexp.MustCompile(`([{|,][ ]*)cluster(=|!=|=~|!~)([ ]*)"([^"]+)"`)
Copy link
Contributor

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.

proxy/pkg/util/util.go Outdated Show resolved Hide resolved
proxy/pkg/util/util.go Outdated Show resolved Hide resolved
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
Copy link
Contributor

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) {
Copy link
Contributor

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.

Comment on lines +141 to +143
go func() {
createFakeServer("3002")
}()
Copy link
Contributor

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?

@@ -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)
Copy link
Contributor

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.

Copy link

sonarcloud bot commented Apr 18, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.9% Coverage on New Code (required ≥ 70%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Copy link

openshift-ci bot commented Apr 18, 2024

@subbarao-meduri: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/test-unit 556698d link true /test test-unit
ci/prow/sonarcloud 556698d link true /test sonarcloud
ci/prow/e2e-kind 556698d link true /test e2e-kind

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.

Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
Signed-off-by: Subbarao Meduri <smeduri@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants