OCPBUGS-87201: Fix RoleBindings tab error for non-cluster-admin users#16639
OCPBUGS-87201: Fix RoleBindings tab error for non-cluster-admin users#16639rhamilto wants to merge 1 commit into
Conversation
|
@rhamilto: This pull request references Jira Issue OCPBUGS-87201, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
Walkthrough
ChangesRBAC access-based watch filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/jira refresh |
|
@rhamilto: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
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. |
|
@rhamilto: This pull request references Jira Issue OCPBUGS-87201, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/lgtm |
|
/retest |
1 similar comment
|
/retest |
When viewing the RoleBindings tab on a project details page, the console unconditionally fetched ClusterRoleBindings at cluster scope, causing a "Restricted access" error for users without cluster-admin permissions. Use an access review to check whether the user can list ClusterRoleBindings. When the check fails (non-cluster-admin), the ClusterRoleBinding watch is omitted, preventing the error. When the check succeeds (cluster-admin), ClusterRoleBindings are fetched regardless of whether a namespace is selected, preserving the "Cluster-wide RoleBindings" Kind filter option on the list page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@rhamilto: This pull request references Jira Issue OCPBUGS-87201, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@cajieh, integration test revealed the original fix was incorrect. Mind taking another look. See https://github.com/openshift/console/compare/fa39cfaf7beb56019cb7ab9a428b5be1d0ca2cc2..4e7a76875c7a7d2134a5899e07e1753e08090dcc |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/public/components/RBAC/bindings.tsx (1)
364-388:⚠️ Potential issue | 🟡 MinorReplace deprecated
useAccessReviewimport with SDK version.Line 58 imports
useAccessReviewfrom'../utils/rbac', which is marked@deprecatedin favor of the version from@console/dynamic-plugin-sdk. Since the file already imports from the SDK, update the import:import { useAccessReview } from '`@console/dynamic-plugin-sdk`';🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/public/components/RBAC/bindings.tsx` around lines 364 - 388, Update the import statement for the useAccessReview hook in the bindings.tsx file. Currently it imports useAccessReview from the deprecated '../utils/rbac' module, but it should instead be imported from '`@console/dynamic-plugin-sdk`' which is the SDK version. Change the import line to pull useAccessReview from '`@console/dynamic-plugin-sdk`' instead of the local utils module. The useAccessReview hook is used to check permissions for canListClusterRoleBindings, so ensure this function reference continues to work after updating the import source.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@frontend/public/components/RBAC/bindings.tsx`:
- Around line 364-388: Update the import statement for the useAccessReview hook
in the bindings.tsx file. Currently it imports useAccessReview from the
deprecated '../utils/rbac' module, but it should instead be imported from
'`@console/dynamic-plugin-sdk`' which is the SDK version. Change the import line
to pull useAccessReview from '`@console/dynamic-plugin-sdk`' instead of the local
utils module. The useAccessReview hook is used to check permissions for
canListClusterRoleBindings, so ensure this function reference continues to work
after updating the import source.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0042e1d4-e42a-4d4b-a708-75d025082adc
📒 Files selected for processing (1)
frontend/public/components/RBAC/bindings.tsx
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cajieh, rhamilto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest |
|
@rhamilto: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |

Analysis / Root cause:
RoleBindingsPageunconditionally watchesClusterRoleBindingsat cluster scope, even when viewing within a namespace. Non-cluster-admin users lack permissions to listClusterRoleBindingsat the cluster scope, causing a "Restricted access" error on the project RoleBindings tab.Solution description:
Use
useAccessReviewto check whether the user haslistpermission onClusterRoleBindings. When the access review fails (non-cluster-admin), theClusterRoleBindingwatch is omitted fromwatchResources, preventing the "Restricted access" error. When the access review succeeds (cluster-admin),ClusterRoleBindingsare fetched regardless of whether a namespace is selected, preserving the "Cluster-wide RoleBindings" Kind filter option on the RoleBindings list page.Screenshots / screen recording:

Test setup:
user1)Test cases:
Browser conformance:
Additional info:
https://redhat.atlassian.net/browse/OCPBUGS-87201
Reviewers and assignees:
Summary by CodeRabbit