Repository navigation
Test proxy-runner RBAC under owner reference admission - #7336
Closed
ChrisJBurns wants to merge 2 commits into
Closed
ChrisJBurns wants to merge 2 commits into
ChrisJBurns wants to merge 2 commits into
Conversation
#7334 enabled OwnerReferencesPermissionEnforcement in the kind e2e clusters, but nothing checks it stays on. Dropping the workflow's config or editing the kubeadm patch would silently remove the guard while every scenario still passed. Add a Chainsaw scenario that expects a blockOwnerDeletion owner reference to be rejected without finalizers RBAC and accepted once it is granted. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A Chainsaw canary only checked that the kind cluster ran the OwnerReferencesPermissionEnforcement plugin. Replace it with an envtest suite that enables the plugin and has the operator-generated proxy-runner Role create a Service owned with blockOwnerDeletion, so the RBAC behind #6835 is tested directly. A control Role without statefulsets/finalizers must be rejected, proving the plugin is on. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7336 +/- ##
==========================================
- Coverage 82.40% 82.40% -0.01%
==========================================
Files 937 937
Lines 95821 95821
==========================================
- Hits 78962 78960 -2
- Misses 16854 16856 +2
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
Folded into #7337. The envtest suite now runs the proxy-runner's real |
4 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#6835 broke OpenShift: its
OwnerReferencesPermissionEnforcementadmission plugin rejected the proxy-runner creating its Services, because they are owned by the StatefulSet withblockOwnerDeletion: trueand the proxy-runner Role lackedupdateonapps/statefulsets/finalizers. #6756 fixed the Role and #7334 turned the plugin on in the kind e2e clusters. As rdimitrov noted in the #7334 review, nothing checks that guard. This PR adds an operator integration test that checks the RBAC directly instead of depending on how CI's kind cluster is configured.cmd/thv-operator/test-integration/mcp-server-ownerref-admission/, whose API server runs withOwnerReferencesPermissionEnforcementenabled. envtest already authorizes with RBAC, which the plugin consults.MCPServerReconcilerreconciles an SSE MCPServer, so the test uses the proxy-runner Role the operator actually generates fromdefaultRBACRules. Acting as that Role's ServiceAccount, the test creates a Service owned by a StatefulSet withblockOwnerDeletion: true, as the runner does, and the create must succeed.statefulsets/finalizersmust be rejected withcannot set blockOwnerDeletion. This proves the plugin is active, so the positive case can't pass vacuously.testutil.SuiteOptionsgainsEnableAdmissionPlugins, so only this suite's API server changes.task operator-test-integration/operator-tests-integrationjob.An earlier revision of this PR added a Chainsaw canary instead; it's replaced, because an envtest Go test is the better fit.
Type of change
Test plan
Manual testing (describe below)
Ran the new suite with envtest 1.31.0 (
ginkgo ./cmd/thv-operator/test-integration/mcp-server-ownerref-admission/): 2/2 specs pass, across several runs with and without-p.Temporarily removed the
statefulsets/finalizersrule fromdefaultRBACRules: the positive case fails withservices "mcp-ownerref-admission-headless" is forbidden: cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on. I then restored the rule.task lint-fixdoesn't run locally: staticcheck panics under Go 1.27 (unexpected expr: *ast.KeyValueExpr). golangci-lint with staticcheck disabled reports 0 issues on the changed packages, andgo vetandgofmtare clean. CI lint covers staticcheck.Special notes for reviewers
blockOwnerDeletion) will need to update this test. That's intended: the test then records whether the grant is still needed.🤖 Generated with Claude Code