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: make SpaceBindingRequest.Spec.MasterUserRecord immutable #470

Merged
merged 8 commits into from
Sep 11, 2023

Conversation

mfrancisc
Copy link
Contributor

@mfrancisc mfrancisc commented Sep 4, 2023

This PR introduces a new validating webhook for SpaceBindingRequests. Specifically the webhook makes sure that once an SBR is created the MasterUserRecord field cannot be changed anymore. Changing the MUR field in SBR will generate an discrepancy with the name of SpaceBinding that will still contain the old MUR.

Jira: https://issues.redhat.com/browse/ASC-426

Paired with: codeready-toolchain/toolchain-e2e#792

@mfrancisc
Copy link
Contributor Author

/retest

updated e2e PR

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Looks good overall 👍 Just a few comments

port: 443
matchPolicy: Equivalent
rules:
- operations: ["CREATE", "UPDATE"]
Copy link
Contributor

Choose a reason for hiding this comment

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

we also need to cover PATCH, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember adding PATCH initially but was failing, since apparently there is not PATCH operations 🤷‍♂️ :https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-rules

operations lists one or more operations to match. Can be "CREATE", "UPDATE", "DELETE", "CONNECT", or "*" to match all.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, OK. My bad - I automatically expected that Patch would be one of the operations as well :-)
Thanks for the link and sorry for confusion 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries, I expected the same and I'm still a bit confused of why are those the "operations". What is connect for example 😕

make/go.mk Outdated
Comment on lines 38 to 39
@rm ./pkg/webhook/deploy/templates/template_assets.go 2>/dev/null || true
@$(GO_BINDATA) -pkg templates -o ./pkg/webhook/deploy/templates/template_assets.go -nocompress -prefix deploy/webhook deploy/webhook
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't webhook (or in plural form webhooks), or webhook_assest be more appropriate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed it to webhooks plz check : 9ddde44

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

func TestHandleValidateRolebBndingAdmissionRequestBlocked(t *testing.T) {
func TestHandleValidateRolebBindingAdmissionRequestBlocked(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is the extra b in Roleb expected?
it's the same also in other names of the test functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While trying to fix a typo I've introduced a new one 🤦‍♂️ . Thanks it should be fixed in 9ddde44

Comment on lines 159 to 161
Labels: map[string]string{
toolchainv1alpha1.ProviderLabelKey: toolchainv1alpha1.ProviderLabelValue,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this label set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the sake of the test we don't , was a copy paste left over I guess. Removed in 9ddde44

@mfrancisc
Copy link
Contributor Author

@MatousJobanek thanks for your review. I've addressed your comments, when you have time PTAL. I've also fixed/updated some unit tests which apparently I've missed initially.

@mfrancisc
Copy link
Contributor Author

@mfrancisc
Copy link
Contributor Author

/retest

updated e2e PR

@mfrancisc
Copy link
Contributor Author

/retest

infra

1 similar comment
@mfrancisc
Copy link
Contributor Author

/retest

infra

@mfrancisc
Copy link
Contributor Author

/retest

infra

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Merging #470 (dd43982) into master (d74bf09) will decrease coverage by 0.29%.
The diff coverage is 63.46%.

@@            Coverage Diff             @@
##           master     #470      +/-   ##
==========================================
- Coverage   82.31%   82.02%   -0.29%     
==========================================
  Files          29       30       +1     
  Lines        3393     3444      +51     
==========================================
+ Hits         2793     2825      +32     
- Misses        455      474      +19     
  Partials      145      145              
Files Changed Coverage
.../validatingwebhook/validate_spacebindingrequest.go 62.74%
pkg/webhook/deploy/deployment.go 100.00%

@sonarqubecloud
Copy link

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
0.0% 0.0% Duplication

@mfrancisc
Copy link
Contributor Author

/retest

infra

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@openshift-ci
Copy link

openshift-ci bot commented Sep 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MatousJobanek, mfrancisc

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

@mfrancisc
Copy link
Contributor Author

/retest

infra

@mfrancisc
Copy link
Contributor Author

/retest

infra

@mfrancisc mfrancisc merged commit eb182b9 into codeready-toolchain:master Sep 11, 2023
8 of 10 checks passed
@mfrancisc mfrancisc deleted the murvalidate branch September 11, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants