Skip to content

OLS-3973 - Fix ClusterRole RBAC breaking operator informers - #1976

Open
JoaoFula wants to merge 1 commit into
openshift:mainfrom
JoaoFula:fix/rbac-informer-clusterrolebindings
Open

OLS-3973 - Fix ClusterRole RBAC breaking operator informers#1976
JoaoFula wants to merge 1 commit into
openshift:mainfrom
JoaoFula:fix/rbac-informer-clusterrolebindings

Conversation

@JoaoFula

@JoaoFula JoaoFula commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Description

PR #1954 (OLS-3886 Tighten ClusterRole RBAC) scoped list and watch on clusterrolebindings and clusterroles to specific resourceNames. The security intent was correct, but it broke the operator:

  • olsconfig_controller.go uses Owns(&rbacv1.ClusterRole{}) and Owns(&rbacv1.ClusterRoleBinding{}), which sets up cluster-wide informers via controller-runtime.
  • Informers do an unfiltered list + watch (no resource-name selector exists at the API level).
  • Kubernetes RBAC denies the unfiltered list because the permission was scoped to resourceNames.
  • The informer can't sync → all caches time out → manager exits → no reconciliation → lightspeed-app-server deployment never created.

Evidence: periodic e2e failure — controller-manager logs show clusterrolebindings.rbac.authorization.k8s.io is forbidden followed by cache sync timeout and manager shutdown.

Fix

Split read-only verbs (unscoped, required by informers) from mutating verbs (scoped to resourceNames, prevents privilege escalation):

  • list + watchunscoped (read-only, not a privilege escalation vector)
  • get + update + deletescoped to resourceNames (unchanged, still pinned)

Security posture preserved

  • create without resourceNames — unchanged (Kubernetes ignores resourceNames on create).
  • list + watch unscoped — read-only, the operator could already read these via its informer before OLS-3886 Tighten ClusterRole RBAC to prevent privilege escalation #1954.
  • update + delete + get scoped to named resources — unchanged, still pinned to operator-managed resources only.
  • RBAC validation tests in internal/rbac/role_yaml_test.go — all pass (they check update/delete/patch are pinned to resourceNames).

Type of change

  • Bug fix

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • make test passes — all unit tests including RBAC validation tests.
  • make manifests regenerates config/rbac/role.yaml correctly from updated kubebuilder markers.
  • Fix verified by tracing the controller-manager logs from the failing CI run: the ClusterRoleBinding informer list call requires unscoped list+watch.

Summary by CodeRabbit

  • Bug Fixes
    • Updated permissions for cluster roles and bindings to support required resource discovery and monitoring.
    • Restricted resource-specific access to only the necessary retrieve, update, and delete operations.
    • No changes to application behavior or functionality.

@openshift-ci
openshift-ci Bot requested review from blublinsky and xrajesh August 21, 2026 14:59
@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown

[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 blublinsky 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

@JoaoFula JoaoFula changed the title fixing rbac OLS-3886 Fix ClusterRole RBAC breaking operator informers Aug 21, 2026
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fb7b4247-df2b-499c-b0ea-353474f0e1e9

📥 Commits

Reviewing files that changed from the base of the PR and between c0d4789 and a6b0931.

⛔ Files ignored due to path filters (1)
  • config/rbac/role.yaml is excluded by !config/rbac/role.yaml
📒 Files selected for processing (2)
  • bundle/manifests/lightspeed-operator.clusterserviceversion.yaml
  • internal/controller/olsconfig_controller.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change updates controller RBAC markers and the ClusterServiceVersion manifest. List and watch permissions are now unscoped for cluster-wide informers. Resource-specific cluster role and binding permissions retain only get, update, and delete.

Changes

Cluster RBAC permission alignment

Layer / File(s) Summary
Align RBAC declarations and generated permissions
internal/controller/olsconfig_controller.go, bundle/manifests/lightspeed-operator.clusterserviceversion.yaml
The controller grants create, list, and watch without resource names. Named cluster roles and cluster role bindings retain get, update, and delete. The ClusterServiceVersion manifest reflects these permissions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a6b09

The change restores operator informer access while keeping mutating permissions limited to managed resources; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: blublinsky, xrajesh, raptorsun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the RBAC fix and its effect on operator informers, matching the main change.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@JoaoFula JoaoFula changed the title OLS-3886 Fix ClusterRole RBAC breaking operator informers OLS-3973 - Fix ClusterRole RBAC breaking operator informers Aug 21, 2026
@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown

@JoaoFula: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/bundle-e2e-4-21 a6b0931 link true /test bundle-e2e-4-21

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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