Skip to content

fix(rbac): add sandboxes/finalizers permission for owner references - #363

Merged
pdettori merged 2 commits into
mainfrom
fix/sandbox-finalizers-rbac
May 15, 2026
Merged

fix(rbac): add sandboxes/finalizers permission for owner references#363
pdettori merged 2 commits into
mainfrom
fix/sandbox-finalizers-rbac

Conversation

@pdettori

Copy link
Copy Markdown
Member

Summary

  • Add sandboxes/finalizers update permission to the operator ClusterRole
  • Fixes Sandbox deployments failing on OpenShift with cannot set blockOwnerDeletion errors
  • Updates kubebuilder markers, generated config/rbac/role.yaml, and Helm chart

Problem

The clientregistration and agentcardsync controllers create Secrets and AgentCards with blockOwnerDeletion owner references pointing to Sandbox CRs. OpenShift enforces that the controller service account must have update permission on the owner resource's finalizers subresource. Without it:

secrets "kagenti-keycloak-client-credentials-<hash>" is forbidden:
  cannot set blockOwnerDeletion if an ownerReference refers to a resource
  you can't set finalizers on

This was not caught on Kind (which does not enforce this RBAC check) but breaks all Sandbox-type agent deployments on OpenShift.

Changes

File Change
clientregistration_controller.go Add +kubebuilder:rbac marker for sandboxes/finalizers
agentcardsync_controller.go Add +kubebuilder:rbac marker for sandboxes/finalizers
config/rbac/role.yaml Add generated rule
charts/.../rbac/role.yaml Add Helm chart rule

Follows the existing pattern for deployments/finalizers and statefulsets/finalizers.

Test plan

  • Verified fix on ROSA 4.19 cluster by patching the ClusterRole live — operator successfully created the missing secret and stuck Sandbox pod recovered to Running
  • CI: verify unit tests pass with updated RBAC markers

Assisted-By: Claude Code

The clientregistration and agentcardsync controllers create Secrets and
AgentCards with blockOwnerDeletion owner references pointing to Sandbox
CRs. OpenShift enforces that the controller SA must have update
permission on the owner resource's finalizers subresource for this to
succeed. Without it, the operator fails with:

  cannot set blockOwnerDeletion if an ownerReference refers to a
  resource you can't set finalizers on

This was not caught on Kind (which does not enforce this check) but
breaks Sandbox deployments on OpenShift.

Add sandboxes/finalizers update permission to the kubebuilder markers,
generated config/rbac, and the Helm chart ClusterRole — matching the
existing pattern for deployments/finalizers and statefulsets/finalizers.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Paolo Dettori <dettori@us.ibm.com>

@cwiklik cwiklik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean RBAC fix — adds sandboxes/finalizers update permission matching the existing deployments/finalizers and statefulsets/finalizers pattern. Kubebuilder markers, generated config/rbac, and Helm chart are all consistent. One pre-existing gap noted below.

Areas reviewed: Go (kubebuilder markers), Helm/K8s (RBAC), YAML
Commits: 1 commit, signed-off: yes
CI status: all passing (E2E pending)

…egistration controller

Address review feedback: the clientregistration controller sets
blockOwnerDeletion owner references on Deployments and StatefulSets too,
so it needs the same finalizers markers that agentcardsync already has.
Pre-existing gap surfaced during sandboxes/finalizers review.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
@pdettori

Copy link
Copy Markdown
Member Author

Addressed: added deployments/finalizers and statefulsets/finalizers markers to clientregistration_controller.go in the latest commit to close the pre-existing gap.

@pdettori
pdettori merged commit 74a2479 into main May 15, 2026
15 checks passed
@pdettori
pdettori deleted the fix/sandbox-finalizers-rbac branch May 15, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants