Repository navigation
Description
Proposal
Stop setting blockOwnerDeletion: true on the owner reference the proxy runner puts on the headless and ClusterIP Services pointing at their StatefulSet. Once that's done, drop the apps/statefulsets/finalizers grant that #6756 adds.
Background
On OpenShift, OwnerReferencesPermissionEnforcement rejects a blockOwnerDeletion: true owner reference unless the caller has update on the owner's /finalizers (#6835). #6756 fixes that by granting statefulsets/finalizers to the proxy-runner Role and to the operator ClusterRole. The operator needs it too because Kubernetes won't let it grant a permission it doesn't hold.
That's the standard fix, but it's RBAC we may not need. The flag only does something when the owner is deleted with foreground propagation: the StatefulSet would wait until its Services are gone. We never delete that way:
RemoveWorkloaddeletes the StatefulSet with emptyDeleteOptions(background) inpkg/container/kubernetes/client.go.finalizeMCPServerdeletes the StatefulSet and both Services by name.- Nothing in production code sets
PropagationPolicyorDeletePropagationForeground.
GC still removes the Services once the StatefulSet is gone, with or without the flag.
Change
pkg/container/kubernetes/client.go,ensureBackendServices: dropBlockOwnerDeletion: ptr.To(true)from the StatefulSet owner reference.pkg/container/kubernetes/client.go, the service apply helper: drop the hardcodedWithBlockOwnerDeletion(true). It ignores whatever the owner passed in says anyway.pkg/container/kubernetes/client_test.go: update the two assertions that expecttrue.- Revert the
apps/statefulsets/finalizersentry indefaultRBACRulesand its+kubebuilder:rbacmarker, then regeneraterole.yaml.
Why it's safe
- Admission rules: the plugin only asks for the finalizers permission when an owner reference is newly blocking or flipped to blocking (source). Removing the flag, or leaving it out, never triggers that check. Any change to owner refs also needs
deleteon the object itself, and the proxy-runner Role already hasdeleteon services. - Existing Services on vanilla clusters: the next Force apply drops the field. That passes even with the plugin on.
- OpenShift: nothing to migrate, because Service creation has failed there since Add ClusterIP service with SessionAffinity for MCP server backend #3992.
- Recreated StatefulSet (new UID): under B this needs no extra permission. Under the current grant approach it needs the finalizers permission every time.
- Coverage: this is the only owner reference the proxy runner sets. The runner creates the StatefulSet with no owner, and the operator later adopts it under the MCPServer.
What B buys over the RBAC grant alone
- Least privilege: with the grant, every MCPServer's runner service account can set blocking owner references on any StatefulSet in its namespace.
- Mixed versions: a newer runner works against an older operator chart that lacks
statefulsets/finalizers.
Related
- Enable
OwnerReferencesPermissionEnforcementintest/e2e/thv-operator/kind-config.yaml(apiServer.extraArgs). The chainsaw job inoperator-ci.ymlcreates its kind cluster without a config and would need one too. This would have caught Add ClusterIP service with SessionAffinity for MCP server backend #3992, and it would prove B in CI. Ideally it lands with or before B.
Open question
@ChrisJBurns, what do you think? Is it worth dropping the flag and shrinking the RBAC footprint, or should we stick with the conventional /finalizers grant from #6756?
Activity
Sanskarzz commentedon Oct 28, 2026
@jhrozek From the operator side, I support dropping blockOwnerDeletion while retaining the StatefulSet owner references. That preserves GC cleanup, including the orphaned-Service case raised in #3992, and our deletion paths do not rely on foreground ordering.
I’d include admission-enabled coverage for both Kind setups, existing-Service updates, StatefulSet UID changes, and eventual cleanup. We should also coordinate with #6756: it is still open, and older runner images still need the grant when creating or rebinding Services. If that grant lands first, let’s agree on the rollout/rollback policy before removing it.
rdimitrov commentedon Nov 26, 2026
I'm folding #7322 into this issue, since both propose the same change. #7322 settles the rollout question raised above, so here is its plan:
apps/statefulsets/finalizersgrant for one release. DropblockOwnerDeletionfirst, but leave the grant indefaultRBACRulesand in the operator's+kubebuilder:rbacmarker. A new operator paired with an older runner pinned throughoperator.toolhiveRunnerImagestill sets the flag, and that would break OpenShift again. Remove the grant in a later release, then runtask operator-manifestsand update the Chainsaw ClusterRole and proxy-runner Role fixtures.upsertRolereplaces a Role's rules wholesale, so existing Roles shrink without a migration./finalizersmarkers. Thetoolhive.stacklok.dev*rule already covers them, but they document the dependency in case*is ever narrowed.Sequencing: land this after #6756 (approved, not merged yet) and after #7321, so CI enforces
OwnerReferencesPermissionEnforcementwhen this goes in.Drop blockOwnerDeletion on runner-owned Services (stacklok#7337)