Skip to content

fix: tighten the VAP rule for all managed resources#1212

Merged
nwnt merged 4 commits into
Azure:mainfrom
nwnt:tighten-managed-resource-rule
Oct 23, 2025
Merged

fix: tighten the VAP rule for all managed resources#1212
nwnt merged 4 commits into
Azure:mainfrom
nwnt:tighten-managed-resource-rule

Conversation

@nwnt

@nwnt nwnt commented Oct 18, 2025

Copy link
Copy Markdown
Contributor

Description of your changes

Fixes # bug that the VAP can be deleted and enhanced it so that it covers all managed resources.

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Tested with unit tests and e2e locally.

Special notes for your reviewer

n/a

@nwnt
nwnt force-pushed the tighten-managed-resource-rule branch from ae2114c to 8b3fada Compare October 18, 2025 03:25
@nwnt nwnt changed the title Tighten the VAP rule for all managed resources fix: tighten the VAP rule for all managed resources Oct 18, 2025
Signed-off-by: Nont <nont@duck.com>
@nwnt
nwnt force-pushed the tighten-managed-resource-rule branch from 8b3fada to 840e808 Compare October 18, 2025 04:18
// Verify initial state
if vap == nil {
t.Fatal("getVAPWithMutator() returned nil VAP")
return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Surprised this is needed - I thought t.Fatal() will not execute further.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I got a lint error/warning from not having this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't remember what it was that gave this warning/error, but I have gone ahead and remove this from it. Let's see if I'm going to get a lint error from the checks.

Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go Outdated
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go
Nont added 2 commits October 21, 2025 13:38
Signed-off-by: Nont <nont@duck.com>
Signed-off-by: Nont <nont@duck.com>
"system:masters" in request.userInfo.groups ||
"system:serviceaccounts:kube-system" in request.userInfo.groups ||
"system:serviceaccounts:fleet-system" in request.userInfo.groups ||
"system:serviceaccounts:openshift-kube-controller-manager" in request.userInfo.groups

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"system:serviceaccounts:openshift-kube-controller-manager" in request.userInfo.groups

You can remove this condition since the new condition added below should properly handle OCP clusters

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That clause is now removed, so is the || operator before it.

Comment thread pkg/webhook/managedresource/validatingadmissionpolicy.go Outdated
Comment thread pkg/webhook/managedresource/validatingadmissionpolicy_test.go
Comment thread test/e2e/managed_resource_vap_test.go
Comment thread test/e2e/managed_resource_vap_test.go Outdated
@nwnt
nwnt merged commit 797eae5 into Azure:main Oct 23, 2025
22 of 24 checks passed
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.

4 participants