fix(rbac): resolve RBAC regression for project-scoped resources in multi-namespace architecture (#25289)#26573
Conversation
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #26573 +/- ##
==========================================
+ Coverage 63.00% 63.21% +0.21%
==========================================
Files 414 414
Lines 56153 56480 +327
==========================================
+ Hits 35378 35703 +325
+ Misses 17410 17405 -5
- Partials 3365 3372 +7 ☔ View full report in Codecov by Sentry. |
d9e4ade to
8a5caa5
Compare
Signed-off-by: tcfwbper <pesci861207@gmail.com>
… proj/ns/app Signed-off-by: tcfwbper <pesci861207@gmail.com>
… project-scoped resources Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
8a5caa5 to
50cc3d7
Compare
…ication_SetWithNormalization. Signed-off-by: tcfwbper <pesci861207@gmail.com>
e120870 to
3bd0def
Compare
|
Dear reviewers, this guide might help you speed up reviewing. The core changes of this PR are:
Almost other changes are corresponding adjustment for unit tests |
|
FYI, I had some tests in my local environment. Setup:
Experiment: Results: all of the results are as expected Screen.Recording.2026-03-15.at.11.39.38.PM.movScreen.Recording.2026-03-15.at.11.55.22.PM.-.Compressed.with.FlexClip.mp4 |
| normalizedPolicy = component | ||
| } else { | ||
| normalizedPolicy = fmt.Sprintf("%s, %s", normalizedPolicy, strings.Trim(component, " ")) | ||
| if _, ok := seen[normalizedPolicy]; ok { |
There was a problem hiding this comment.
| if _, ok := seen[normalizedPolicy]; ok { | |
| for i, role := range proj.Spec.Roles { | |
| proj.Spec.Roles[i].Policies = normalizeUniquePolicies(role.Policies, proj.Namespace) | |
| } |
| } | ||
| return false, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
| // normalizeUniquePolicies normalizes and deduplicates a slice of policy strings. | |
| func normalizeUniquePolicies(policies []string, namespace string) []string { | |
| watched := make(map[string]struct{}, len(policies)) | |
| result := make([]string, 0, len(policies)) | |
| for _, policy := range policies { | |
| normalized := rbac.NormalizePolicy(policy, namespace) | |
| if _, ok := watched[normalized]; ok { | |
| continue | |
| } | |
| watched[normalized] = struct{}{} | |
| result = append(result, normalized) | |
| } | |
| return result | |
| } |
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
Signed-off-by: tcfwbper <pesci861207@gmail.com>
|
@ishitasequeira tagged you since you reviewed the approach |
Summary
This PR fixes the RBAC regression for project-scoped resources in multi-namespace architecture (#25289)
The issue was caused by inappropriate migration when we introduced "applications in any namespaces".
I have updated the following areas to restore the expected behavior:
Checklist
Fixes #25289