Skip to content

Enforce owner reference permissions in kind e2e - #7334

Merged
ChrisJBurns merged 1 commit into
mainfrom
ChrisJBurns/kind-ownerref-admission
Nov 26, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
ChrisJBurns/kind-ownerref-admission

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

OpenShift enables the OwnerReferencesPermissionEnforcement admission plugin. It rejects any object whose ownerReference sets blockOwnerDeletion: true unless the caller can update the owner's <resource>/finalizers. Our kind clusters don't enable it, so the missing statefulsets/finalizers grant (#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.

  • Enable NodeRestriction,OwnerReferencesPermissionEnforcement in test/e2e/thv-operator/kind-config.yaml. NodeRestriction stays because the flag replaces kubeadm's default list.
  • Point the e2e-tests-operator Chainsaw job in operator-ci.yml at that config. It used kind's defaults before, so the plugin wasn't on for the per-PR job. test-e2e-lifecycle.yml and task kind-setup-e2e already use this file.
  • Note in .claude/rules/testing.md that kind-setup-e2e has the plugin, so local Chainsaw runs can match CI.

Closes #7321

Type of change

  • Other (describe): CI / test infrastructure

Test plan

  • Manual testing (describe below)

On a kindest/node:v1.35.1 cluster 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 no statefulsets/finalizers was refused when creating a ConfigMap owned by a StatefulSet with blockOwnerDeletion: true (cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on). After granting apps statefulsets/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

  • Reusing the kind config: the Chainsaw job now gets the 30000-30020 NodePort range and host port mappings too. The port mappings don't matter on a runner. The range has room for the few LoadBalancer Services Chainsaw creates at once.
  • Follow-up: Drop blockOwnerDeletion on proxy-runner owned Services #6836, which drops blockOwnerDeletion on proxy-runner Services, should land after this so CI enforces the plugin when it goes in.

🤖 Generated with Claude Code

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]>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Nov 26, 2026
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.40%. Comparing base (eb40663) to head (f4809b8).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov rdimitrov left a comment

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.

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) with kindest/node:v1.35.1. The kube-apiserver manifest has --enable-admission-plugins=NodeRestriction,OwnerReferencesPermissionEnforcement and keeps --service-node-port-range=30000-30020. The Chainsaw job log for this PR shows helm/kind-action got config: 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 assert mcp-<name>-headless exists, 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 NodePort explicitly. 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.

@ChrisJBurns
ChrisJBurns merged commit 9300f3f into main Nov 26, 2026
58 of 59 checks passed
@ChrisJBurns
ChrisJBurns deleted the ChrisJBurns/kind-ownerref-admission branch November 26, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable OwnerReferencesPermissionEnforcement in kind e2e clusters

2 participants