Skip to content

fix(home): scope topology preview legend by ns + count restricted ns (#655)#735

Merged
nadaverell merged 1 commit into
mainfrom
fix/655-home-ns-scoping
May 19, 2026
Merged

fix(home): scope topology preview legend by ns + count restricted ns (#655)#735
nadaverell merged 1 commit into
mainfrom
fix/655-home-ns-scoping

Conversation

@nadaverell
Copy link
Copy Markdown
Contributor

@nadaverell nadaverell commented May 19, 2026

Summary

Two of the three follow-ups from #655 (per-user RBAC visual-test pass on #609). Item #2 from that issue is intentionally left out — it's a product call, not a clear fix.

1. Home topology preview: legend stayed cluster-wide when a namespace was picked

The SSE topology stream is cluster-wide for small/medium clusters; only the dashboard summary (the "X resources · Y conn" header) is namespace-filtered server-side. So picking a namespace updated the header but left the kind legend reflecting cluster-wide totals.

Verified end-to-end on prod-cluster-us-east1 with the autopush namespace selected:

Header Legend
Pre-fix 4 resources · 2 conn 65 Deployment · 37 DaemonSet · 5 StatefulSet · 70 Service · 16 Ingress · 1 Gateway · 8 HTTPRoute · 133 Pod … (cluster-wide)
Post-fix 4 resources · 2 conn 1 Deployment · 1 Pod · 1 ConfigMap · 1 GatewayClass (matches header)

Fix: a scopedTopology memo in HomeView filters the topology to the active namespace set on the client (cluster-scoped nodes pass through, dangling edges dropped) before passing it to TopologyPreview and ActivitySummary. No-op on large clusters (≥1000 nodes) where forceNamespaceFilter already filters SSE server-side.

2. Cluster info card: "0 namespaces" for restricted users

dashboard.go only populated ResourceCounts.Namespaces when the user could list namespaces cluster-wide. For users restricted to N specific namespaces (no cluster-wide SAR), the count stayed at 0 — misleading. Fall back to len(allowedNamespaces), mirroring the same pattern already in resource_counts.go.


Note

Low Risk
Low risk: changes are limited to dashboard display logic (client-side topology filtering) and a small server-side fallback for namespace counts, with no auth or data-write behavior modified.

Overview
Fixes mismatches on the Home dashboard when a namespace filter is active by client-filtering the SSE topology before rendering, so TopologyPreview and ActivitySummary legends/edges align with the namespace-scoped summary.

Also corrects the cluster info/resource counts for RBAC-restricted users by reporting the number of accessible namespaces when the user cannot list namespaces cluster-wide (instead of showing 0).

Reviewed by Cursor Bugbot for commit 2056fb0. Bugbot is set up for automated code reviews on this repo. Configure here.

@nadaverell nadaverell requested a review from hisco as a code owner May 19, 2026 11:42
Two follow-ups from #655 on per-user RBAC visual test:

1. Topology preview card on Home: the SSE topology stream is cluster-
   wide for small/medium clusters; only the dashboard summary is
   namespace-filtered server-side. That left the kind legend showing
   cluster-wide totals while the "<X> resources · <Y> conn" header had
   already narrowed to the active namespace. Filter the topology
   client-side in HomeView before passing it to TopologyPreview (and
   ActivitySummary) so the legend matches the title. No-op on large
   clusters where forceNamespaceFilter already filters SSE server-side.

2. Cluster info card "0 namespaces" for restricted users: dashboard.go
   only populated resourceCounts.Namespaces when the user could list
   namespaces cluster-wide, leaving a misleading "0" for users with a
   restricted namespace view. Fall back to len(allowedNamespaces),
   mirroring the same pattern in resource_counts.go.

Item #2 from the issue (sidebar count "1" vs page "No Namespace found"
asymmetry) is left as-is — genuine product call, neither option is
obviously better than the other.
@nadaverell nadaverell force-pushed the fix/655-home-ns-scoping branch from 573c196 to 2056fb0 Compare May 19, 2026 12:09
@nadaverell nadaverell merged commit 80db37c into main May 19, 2026
8 checks passed
@nadaverell nadaverell deleted the fix/655-home-ns-scoping branch May 19, 2026 12:18
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