Repository navigation
Add /finalizers subresource for OKD/OpenShift installs - #6756
Conversation
|
Hi @Gentoli, thank you for raising the PR regarding the bug. If possible, could you please submit a GitHub Issue (Bug Report) so that we can track it more easily? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6756 +/- ##
==========================================
+ Coverage 81.25% 82.22% +0.96%
==========================================
Files 880 932 +52
Lines 89960 94564 +4604
==========================================
+ Hits 73099 77754 +4655
+ Misses 16856 16805 -51
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The operator cannot grant statefulsets/finalizers to proxy-runner Roles without holding it, so RBAC escalation prevention rejected the Role. Declare it, plus the virtualmcpservers and mcpremoteproxies finalizers, as kubebuilder markers so role.yaml is generated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for tracking this down @Gentoli. I opened #6835 for it, as @Sanskarzz asked, and linked it from the description. I also pushed a commit to your branch (ae8d7c4) because the e2e failures came from this change. Kubernetes won't let anyone grant an RBAC permission they don't hold themselves. The operator builds the proxy-runner Role from Note that this broke vanilla clusters, not just OpenShift.
As you mentioned, the toolhive Separately, we'll probably follow up by dropping |
|
/retest |
The operator e2e setup asserts the exact operator ClusterRole, so the new statefulsets, mcpremoteproxies and virtualmcpservers finalizer rules made the assertion fail. Mirror them in both tenancy fixtures. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The MCPServer scenarios assert the proxy-runner Role positionally against defaultRBACRules, which now includes statefulsets/finalizers. Add the rule to the stdio and HTTP fixtures for both tenancy modes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
The fix looks right to me, and I confirmed it on a cluster that enforces the same check as OpenShift. One upgrade requirement should be called out. What I checkedThe proxy runner sets owner references in only two places, I ran it on kind with
Upgrade requirementThe new operator binary needs the new ClusterRole rule. Otherwise it can't grant the rule to proxy-runner Roles. If the image is upgraded without the chart (only
Could the description get a "user-facing change" section saying the operator ClusterRole now needs Follow-ups#7321 (enable the plugin in kind e2e) and #6836 (drop 🤖 Generated with Claude Code |
rdimitrov
left a comment
There was a problem hiding this comment.
LGTM. I confirmed the fix on a kind cluster with OwnerReferencesPermissionEnforcement turned on (details in the comment above). Please add the operator ClusterRole requirement to the user-facing section or the release notes before the next release.
OpenShift runs the OwnerReferencesPermissionEnforcement admission plugin, which rejects blockOwnerDeletion owner references unless the caller can update the owner's finalizers. Kind doesn't, so the missing statefulsets/finalizers grant fixed in #6756 only showed up on OpenShift. Enable the plugin in the operator e2e kind config and point the Chainsaw job at it so CI catches this class of RBAC gap. Closes #7321 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
OpenShift runs the OwnerReferencesPermissionEnforcement admission plugin, which rejects blockOwnerDeletion owner references unless the caller can update the owner's finalizers. Kind doesn't, so the missing statefulsets/finalizers grant fixed in #6756 only showed up on OpenShift. Enable the plugin in the operator e2e kind config and point the Chainsaw job at it so CI catches this class of RBAC gap. Closes #7321 Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
The runner no longer sets blockOwnerDeletion, so neither the proxy-runner Role nor the operator ClusterRole needs update on apps/statefulsets/finalizers. The grant from #6756 has not shipped in a release, so there is no mixed-version runner to keep working. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
* Drop blockOwnerDeletion on runner-owned Services The proxy runner set blockOwnerDeletion on the StatefulSet owner reference of its headless and ClusterIP Services. Under OwnerReferencesPermissionEnforcement (OpenShift) that requires update on apps/statefulsets/finalizers. The flag only affects foreground cascading deletion, which toolhive never uses, so it bought nothing but an extra RBAC requirement. GC still removes the Services when the StatefulSet is deleted. The statefulsets/finalizers grant stays for one release so a new operator paired with an older pinned runner image keeps working. Closes #6836 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Remove the statefulsets/finalizers grant The runner no longer sets blockOwnerDeletion, so neither the proxy-runner Role nor the operator ClusterRole needs update on apps/statefulsets/finalizers. The grant from #6756 has not shipped in a release, so there is no mixed-version runner to keep working. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Test the runner under ownerref admission Run the proxy-runner's real DeployWorkload, as its ServiceAccount with the operator-generated Role, against an envtest API server with OwnerReferencesPermissionEnforcement enabled. Both Services must be created without the finalizers grant, and a blockOwnerDeletion owner reference must be rejected, which proves the plugin is on and pins that the grant is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Summary
/finalizersupdate role for SAsOCP requires explicit
/finalizersupdate permission on the parent when creating a resource with owner ref. See https://bugzilla.redhat.com/show_bug.cgi?id=1886142#c6proxyrunnercrashes withoutstatefulsets/finalizers:{"time":"2026-10-06T04:06:34Z","level":"ERROR","msg":"error executing command","error":"failed to set up workload: failed to create container: failed to create headless service: failed to apply service mcp-fetch-headless: services \"mcp-fetch-headless\" is forbidden: cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on: , <nil>"}I also added these for some toolhive CRD as missing flagged by LLM. This is not strictly necessary given there is an update
*permission ({"apiGroups":["toolhive.stacklok.dev"],"resources":["*"],"verbs":["get","list","update"]}) that was covering all the/finalizers. Without the*the operator logs:Fixes #6835
Type of change
Test plan
task test)task test-e2e)task lint-fix)API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.Does this introduce a user-facing change?
Yes. The operator ClusterRole now needs
updateonapps/statefulsets/finalizers, because the operator grants that permission to each proxy-runner Role and Kubernetes only lets it grant permissions it holds.OwnerReferencesPermissionEnforcement), SSE and streamable-http MCPServers crash-loop because the proxy runner can't create its Services.Upgrade note: upgrade the operator image and the chart's ClusterRole together. If you bump only
operator.image, or manage the operator's RBAC outside the chart, add this rule to the operator ClusterRole yourself:Without it, on any cluster, new MCPServers fail with
attempting to grant RBAC permissions not currently held, and existing MCPServers goReady=Falseand stop reconciling.Special notes for reviewers
Follow-ups: #7321 enables
OwnerReferencesPermissionEnforcementin the kind e2e clusters so CI catches this class of bug. #6836 stops settingblockOwnerDeletionon the proxy-runner Services; keep the grant from this PR for at least one release after that, since older pinned runner images still set the flag.