Skip to content

HYPERFLEET-1040 - fix: Use label selector to clean up orphaned cluster-scoped RBAC resources#92

Open
rh-amarin wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
rh-amarin:HYPERFLEET-1040
Open

HYPERFLEET-1040 - fix: Use label selector to clean up orphaned cluster-scoped RBAC resources#92
rh-amarin wants to merge 1 commit intoopenshift-hyperfleet:mainfrom
rh-amarin:HYPERFLEET-1040

Conversation

@rh-amarin
Copy link
Copy Markdown
Contributor

@rh-amarin rh-amarin commented May 8, 2026

This is related to changes here: openshift-hyperfleet/hyperfleet-adapter#112

The cleanup function was deleting ClusterRole/ClusterRoleBinding by name, which couples it to the chart's naming scheme.

Switch to label-based deletion using app.kubernetes.io/instance so the cleanup works correctly regardless of how the chart names these resources.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cleanup of orphaned Helm cluster-scoped resources by switching to label-based selection and tolerating missing resources. This reduces leftover cluster roles and bindings and avoids deletion errors for charts that use non-standard resource names, improving reliability during uninstall and upgrade operations.

@openshift-ci openshift-ci Bot requested review from tirthct and vkareh May 8, 2026 14:52
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 8, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign pnguyen44 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 1be902ee-cc99-4a92-97e7-00553661a337

📥 Commits

Reviewing files that changed from the base of the PR and between 7f47014 and 1366a3a.

📒 Files selected for processing (1)
  • pkg/helper/adapter.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/helper/adapter.go

Walkthrough

The cleanupClusterScopedResources function in pkg/helper/adapter.go was changed to delete Helm cluster-scoped resources by label selector instead of by explicit resource names. It constructs the label selector app.kubernetes.io/instance=<releaseName> and invokes kubectl delete for clusterrole and clusterrolebinding with -l <labelSelector> and --ignore-not-found=true to avoid errors when resources are absent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: using label selectors instead of resource names for cleaning up cluster-scoped RBAC resources.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@rh-amarin
Copy link
Copy Markdown
Contributor Author

/test lint

…r-scoped RBAC resources

The cleanup function was deleting ClusterRole/ClusterRoleBinding by name,
which couples it to the chart's naming scheme. Switch to label-based
deletion using app.kubernetes.io/instance so the cleanup works correctly
regardless of how the chart names these resources.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant