Skip to content

fix: grant the bundle RBAC to the OLM v1 installer ServiceAccount [release-2.1] - #3924

Closed
zdrapela wants to merge 1 commit into
redhat-developer:release-2.1from
zdrapela:fix/olm-v1-installer-rbac-2.1
Closed

zdrapela wants to merge 1 commit into
redhat-developer:release-2.1from
zdrapela:fix/olm-v1-installer-rbac-2.1

Conversation

@zdrapela

@zdrapela zdrapela commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Description

OLM v1 installs a bundle with a dedicated installer ServiceAccount, and the API server refuses to create RBAC that grants permissions the installer does not hold itself. The installer ClusterRole rendered by prepare-restricted-environment.sh was not updated when the operator gained access to pods, apiservers/ingresses and the DevHubPluginCatalog CRD, so the OLM v1 path fails with:

failed to create resource: clusterroles.rbac.authorization.k8s.io "rhdh-operator.v2.2-..." is forbidden: ... attempting to grant RBAC permissions not currently held: {pods}, {apiservers}, {ingresses}, {devhubplugincatalogs}, {devhubplugincatalogs/status}

The Helm release then fails halfway: the CRD, the Deployment and the ClusterRoleBinding exist, so the operator pod runs without any permissions and reports forbidden for every resource it watches.

This adds the missing rules and make check-installer-rbac, which compares the installer ClusterRole with the bundle CSV and the ClusterRoles shipped in the bundle, so the two cannot drift again. The check fails on the current main and passes with the fix.

Which issue(s) does this PR fix or relate to

Jira: https://redhat.atlassian.net/browse/RHDHBUGS-4056

Found while fixing the RHDH disconnected OCP nightly jobs: redhat-developer/rhdh#5709

Backport of #3923.

PR acceptance criteria

  • Tests
  • Documentation

How to test changes / Special notes to the reviewer

make check-installer-rbac

On main it reports the 14 missing permissions; with this PR it passes.

@zdrapela
zdrapela requested a review from a team as a code owner October 24, 2026 10:19
@rhdh-qodo-merge

Copy link
Copy Markdown

PR Summary by Qodo

Fix OLM v1 installer RBAC and prevent bundle permission drift

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes


AI Description

• Grant the OLM v1 installer permissions needed to create the bundle’s RBAC.
• Check installer permissions against both bundle CSVs and shipped ClusterRoles to catch future
 drift.
• Run the check in CI when relevant files change.
Diagram

graph TD
  CI["PR workflow"] --> Check["RBAC check"] --> Coverage{"Permissions covered?"} --> Pass["Check passes"]
  Coverage --> Fail["Missing rules"]
  Bundle["Bundle RBAC"] --> Check
  Installer["Installer role"] --> Check
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Generate installer RBAC from bundle permissions
  • ➕ Would reduce manual drift between the bundle and installer role.
  • ➖ Would need to preserve installer-only bootstrap and lifecycle permissions.
  • ➖ Adds generation changes beyond the scope of this backport.

Recommendation: Keep the explicit role and add the coverage check for this backport: it fixes the installation failure without changing how the role is rendered. Generating the role from bundle permissions is worth considering separately if manual drift continues.

Files changed (4) +171 / -4

Bug fix (1) +7 / -4
prepare-restricted-environment.shGrant missing permissions to the rendered installer ClusterRole +7/-4

Grant missing permissions to the rendered installer ClusterRole

• Adds pod access, OpenShift apiserver and ingress reads, and DevHubPluginCatalog and status permissions. These grants allow the OLM v1 installer to create the RBAC required by the bundle.

.rhdh/scripts/prepare-restricted-environment.sh

Other (3) +164 / -0
installer-rbac-check.yamlRun installer RBAC coverage checks on relevant pull requests +43/-0

Run installer RBAC coverage checks on relevant pull requests

• Adds a pull-request workflow for main and release branches. It installs yq and runs the Make target when RBAC-related files change.

.github/workflows/installer-rbac-check.yaml

MakefileExpose the installer RBAC check as a Make target +4/-0

Expose the installer RBAC check as a Make target

• Adds the phony check-installer-rbac target for local use and CI.

Makefile

check-installer-rbac.shDetect bundle permissions missing from installer RBAC +117/-0

Detect bundle permissions missing from installer RBAC

• Extracts the installer ClusterRole and compares its permissions with both bundle CSVs and shipped ClusterRoles. It reports missing group, resource, and verb combinations and exits unsuccessfully when coverage is incomplete.

hack/check-installer-rbac.sh

@rhdh-qodo-merge

rhdh-qodo-merge Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1)



View medium (2)
🟠 **Medium**
1. Bundle role edits bypass the RBAC check 🐞 Bug
Description
The workflow's bundle file filter includes CSV manifests but excludes the ClusterRole manifests read
by check-installer-rbac.sh. When a pull request changes only a shipped ClusterRole, any_changed
remains false and the check is skipped even if that role adds permissions the installer cannot
grant.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Changes to shipped bundle ClusterRoles can add required installer permissions without triggering the new check.
## Fix Focus Areas
- .github/workflows/installer-rbac-check.yaml[25-32]
## Recommended Fix
Add a changed-files pattern covering the bundle ClusterRole YAML files read by the script, or watch all bundle manifests.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Cleanup failures can fail the check 📘 Rule violation
Description
The EXIT trap runs rm -rf "${tmp_dir}" without neutralizing its exit status. If cleanup fails
while set -e is active, the trap can replace the intended result and make the installer RBAC check
fail even after the validation itself succeeds.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The EXIT trap performs filesystem cleanup under `set -euo pipefail`, but the cleanup command is not guarded against failure. A cleanup error can alter the script's final exit status and produce a false failure in CI.

## Fix Focus Areas
- hack/check-installer-rbac.sh[49-50]

## Recommended Fix
Make the EXIT cleanup explicitly best effort by changing the `rm -rf` command to tolerate failure, for example with `|| true` or `|| :`, while keeping the temporary directory path quoted.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



View low (1)
🟡 **Low**
3. Release pull requests skip the RBAC check 🐞 Bug
Description
The workflow uses release-[0-9]+.[0-9]+ as a branch filter, but GitHub Actions treats branch
filters as globs rather than regular expressions. A pull request targeting release-2.1 does not
match that pattern, so this workflow never runs for the release branch targeted by this backport.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new workflow's regex-like branch filter does not match release branches such as `release-2.1`, so the check does not run for their pull requests.
## Fix Focus Areas
- .github/workflows/installer-rbac-check.yaml[4-8]
## Recommended Fix
Replace the release filter with a GitHub Actions glob that matches the repository's release branch names, such as `release-*.*`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



@rhdh-qodo-merge

Copy link
Copy Markdown

Important

The /generate_labels command by Qodo was deprecated on the 1st of October 2026 and is no longer available. We recommend switching to the latest Qodo review capabilities. Learn more

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.1.0-pr-3924-7c924b7 quay.io/rhdh-community/operator:2.1.0-pr-3924
Bundle quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924-7c924b7 quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924
Catalog quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924-7c924b7 quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924

@zdrapela
zdrapela force-pushed the fix/olm-v1-installer-rbac-2.1 branch 2 times, most recently from ad1d1d8 to e6cf8eb Compare October 24, 2026 10:50
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.1.0-pr-3924-e6cf8eb quay.io/rhdh-community/operator:2.1.0-pr-3924
Bundle quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924-e6cf8eb quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924
Catalog quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924-e6cf8eb quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924

prepare-restricted-environment.sh renders an installer ClusterRole for the
OLM v1 path. OLM installs the bundle with that ServiceAccount, and the API
server refuses to create RBAC that grants permissions the installer does not
hold itself ("attempting to grant RBAC permissions not currently held").

The role was not updated when the operator gained access to pods, apiservers,
ingresses and the DevHubPluginCatalog CRD, so OLM v1 installs fail with:

  failed to create resource: clusterroles.rbac.authorization.k8s.io
  "rhdh-operator.v2.2-..." is forbidden: ... attempting to grant RBAC
  permissions not currently held: {pods}, {apiservers}, {ingresses},
  {devhubplugincatalogs}, {devhubplugincatalogs/status}

The Helm release fails halfway: the CRD, the Deployment and the
ClusterRoleBinding are created, so the operator pod runs without any
permissions and reports "forbidden" for every resource it watches.

Add the missing rules, and a check (make check-installer-rbac) that compares
the installer role with the bundle CSV and the ClusterRoles shipped in the
bundle so they cannot drift again.

Assisted-by: OpenCode
@zdrapela
zdrapela force-pushed the fix/olm-v1-installer-rbac-2.1 branch from e6cf8eb to 0203abf Compare October 26, 2026 08:24
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

✅ PR images built and pushed successfully!

Images are available for testing (expires in 7 days):

Image Full tag PR tag
Operator quay.io/rhdh-community/operator:2.1.0-pr-3924-0203abf quay.io/rhdh-community/operator:2.1.0-pr-3924
Bundle quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924-0203abf quay.io/rhdh-community/operator-bundle:2.1.0-pr-3924
Catalog quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924-0203abf quay.io/rhdh-community/operator-catalog:2.1.0-pr-3924

@zdrapela

Copy link
Copy Markdown
Member Author

Replaced with #3927

@zdrapela zdrapela closed this Oct 26, 2026
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.

2 participants