Repository navigation
Enforce owner reference permissions in kind e2e - #7334
Conversation
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7334 +/- ##
=======================================
Coverage 82.40% 82.40%
=======================================
Files 937 937
Lines 95821 95821
=======================================
+ Hits 78958 78959 +1
+ Misses 16858 16857 -1
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
left a comment
There was a problem hiding this comment.
LGTM. Matches #7321, and I checked it on real clusters.
What I ran
- The plugin is on. I built a kind cluster from this
kind-config.yaml(host port mappings removed) withkindest/node:v1.35.1. The kube-apiserver manifest has--enable-admission-plugins=NodeRestriction,OwnerReferencesPermissionEnforcementand keeps--service-node-port-range=30000-30020. The Chainsaw job log for this PR showshelm/kind-actiongotconfig: test/e2e/thv-operator/kind-config.yaml. - It catches the bug it's meant to catch. On that cluster I installed the released v0.69.1 operator chart, which is older than #6756, and applied a streamable-http MCPServer. The proxy-runner crash-loops with
failed to create headless service: ... services "mcp-neg-headless" is forbidden: cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on. That's #6835. The Chainsaw HTTP scenarios assertmcp-<name>-headlessexists, so this gap would now fail CI. With #6756 in the base, the Chainsaw job and all three E2E Lifecycle jobs pass with the plugin on. - The smaller NodePort range is fine for Chainsaw. Chainsaw creates at most four LoadBalancer Services at once (one per single-tenancy transport scenario). The proxy-runner only makes a NodePort Service when a port sets
NodePortexplicitly. 21 ports is plenty.
One correction, for follow-up planning (not blocking)
The kind 1.36 note in the PR body and in #7321 doesn't hold with kind v0.33.0. I created a kindest/node:v1.36.1 cluster from this same config. kind generated a kubeadm.k8s.io/v1beta4 config and turned the map-form extraArgs into the list form (- name: enable-admission-plugins / value: NodeRestriction,OwnerReferencesPermissionEnforcement, and likewise for service-node-port-range). Both flags were on the apiserver. Neither patch needs rewriting for the Renovate bump to 1.36.
Optional hardening
Nothing checks that the plugin is actually on. If a later change drops config: from the workflow or edits this patch, Chainsaw still passes and the check is gone without anyone noticing. A small canary step would make it check itself: create a ServiceAccount without statefulsets/finalizers, then expect an error: when it creates an object with blockOwnerDeletion: true. Fine as a follow-up.
Summary
OpenShift enables the
OwnerReferencesPermissionEnforcementadmission plugin. It rejects any object whose ownerReference setsblockOwnerDeletion: trueunless the caller canupdatethe owner's<resource>/finalizers. Our kind clusters don't enable it, so the missingstatefulsets/finalizersgrant (#6835, fixed in #6756) only showed up for OpenShift users. With the plugin on in CI, this class of RBAC gap fails Chainsaw instead of reaching users.NodeRestriction,OwnerReferencesPermissionEnforcementintest/e2e/thv-operator/kind-config.yaml.NodeRestrictionstays because the flag replaces kubeadm's default list.e2e-tests-operatorChainsaw job inoperator-ci.ymlat that config. It used kind's defaults before, so the plugin wasn't on for the per-PR job.test-e2e-lifecycle.ymlandtask kind-setup-e2ealready use this file..claude/rules/testing.mdthatkind-setup-e2ehas the plugin, so local Chainsaw runs can match CI.Closes #7321
Type of change
Test plan
On a
kindest/node:v1.35.1cluster created from this config (with the host port mappings dropped locally to avoid a port clash), the kube-apiserver ran with--enable-admission-plugins=NodeRestriction,OwnerReferencesPermissionEnforcement. A ServiceAccount with create on configmaps but nostatefulsets/finalizerswas refused when creating a ConfigMap owned by a StatefulSet withblockOwnerDeletion: true(cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on). After grantingappsstatefulsets/finalizers: update, the same create succeeded. I didn't run the full Chainsaw suite locally; this PR's CI run is its first run with the plugin on.Special notes for reviewers
blockOwnerDeletionon proxy-runner Services, should land after this so CI enforces the plugin when it goes in.🤖 Generated with Claude Code