Repository navigation
Add Reflector support for ConfigMaps and Secrets - #1740
Conversation
PR Summary by QodoShow authorized Reflector relationships in topology and resource details
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1.
|
e7bf3cc to
4d937b2
Compare
5399a00 to
48bb368
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
â Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 48bb368. Configure here.
## Why A ConfigMap or Secret can look unused because Radar cannot see its consumer. For example, a workload can consume a Reflector mirror in another namespace while the audit is displaying only the source namespace. Suggesting deletion from that incomplete view is misleading. This PR makes the unused ConfigMap/Secret check distinguish observed use, supported evidence of no use, and unknown evidence. It builds on the subject authorization and incomplete-scan presentation merged in #1753, and reuses the Reflector metadata parser from #1740. It has no remaining prerequisite on the deferred discovery work in #1750. ## Behavior | Available evidence | Result | |---|---| | An observed supported reference uses the object | Count it as evaluated and passing, even if other consumer inventories are unavailable | | No reference, with adequate readable and initially synced consumer inventories | Report the object as unused | | No reference, with a required inventory unavailable or incomplete for the subject namespace | Exclude it from both findings and passing/evaluated counts; disclose incomplete reference evidence | The namespace picker selects subjects. For Reflector-annotated subjects, the collector can inspect authorized consumers of remote mirrors. Use propagates through observed same-kind links, including chains and cycles. Unused automatic mirrors with visible sources are exempt, but their existence does not establish source use. Typed workload, ServiceAccount and Ingress inventories use the existing per-kind readiness and namespace-scope APIs. The existing dynamic reference handlers share a registry with their ConfigMap/Secret and cross-namespace requirements, so discovery and collection agree about which installed integrations matter. An installed but unsynced consumer kind is unknown, not empty. Partial discovery of a relevant group prevents an absence claim; unrelated discovery failures do not. Cert-manager Issuer credential references cover ACME, CA, Vault and Venafi fields. ClusterIssuer credentials use the namespace established by an observed controller's explicit flag, including a literal or downward-API environment value. Hidden controllers, unresolved values or configuration files without an explicit namespace flag do not produce a guessed namespace. Explicit flags take precedence over configuration files. An authorized, synced, empty ClusterIssuer inventory needs no controller namespace. ## Scope and tradeoffs The runtime change stays in the audit collector and orphan check. It adds no shared discovery lifecycle, informer failure latch, permission grants, new watches, scan-cache redesign or coverage response schema. Existing `missingInputs` carries `configmap-references` and `secret-references` through REST, Home, AI context and MCP. Tests in the HTTP/MCP adapters keep their authorization assertions while explicitly supplying the core-only inventory they depend on. Full-access users can also lose unsupported orphan findings while required inventories are still syncing. Restricted users can see fewer orphan evaluations when an installed integration can reference Secrets across namespaces. This is deliberate: an omitted unknown evaluation is preferable to an unsupported deletion suggestion. Known use still counts. The check covers supported reference fields, not arbitrary controller behavior. Existing Istio gateway workload-namespace and Contour delegated TLS resolution limitations are outside this change. Readiness here means initial synchronization, not continuous watch freshness. The existing scan memo can lag evidence changes by up to five seconds. The per-resource audit endpoint retains its findings-array shape and has no completeness metadata; the scan and AI resource context provide that distinction. Package callers that omit `ConfigReferenceEvidence` can establish observed use but cannot establish absence. ## Validation - `make test`, `make tsc`, and `make build` passed. - Race tests passed for `pkg/audit`, `pkg/configrefs`, and the affected audit/server/MCP scenarios. - Live tests used the existing GitOps demo cluster with an explicit kubectl context. Local and authenticated full-access results matched exactly; Secret-denied identities disclosed missing inputs without Secret findings. Alternating and concurrent identities retained separate results. - A temporary ConfigMap-only Reflector fixture exercised the central case. Complete visibility evaluated two subjects, with the remotely consumed source passing and the unused ConfigMap reported. A source-namespace-only cache evaluated only the unused ConfigMap and reported `configmap-references` for the unknown source. Configured REST, dashboard, MCP and the rendered Checks page preserved that warning. - Live test fixtures and processes were removed. No Kubernetes grants or current-context changes. One actual embedded-UI screenshot verified the warning; no frontend source changes.

Summary
Add EmberStack Reflector support to Secret and ConfigMap details and resource topology. Operators can follow a configuration's source and visible mirrors, inspect reflection settings and recorded copy evidence, and spot local configuration mistakes without treating restricted visibility as a missing or unused object.
Follow-up to #1710. The companion audit PR #1741 uses the identical shared dependency parser; either PR can merge first.
Resource details
A Reflector section explains source and mirror roles, automatic versus manual mirrors, reflection permission, and configured namespace rules. Sources and visible mirrors link to the existing resource drawers. Name patterns and label selectors are shown as alternatives within each rule; Radar does not evaluate controller regexes or predict a destination set. Large visible-mirror lists initially show ten entries with an expansion control.
Mirrors show the recorded source version and copy time. When an authorized source is present in the topology snapshot, the section compares its observed resource version with the mirror's recorded version. Cached versions can lag reconciliation. The result is explicitly metadata evidence: metadata-only source edits change versions, while local mirror edits may preserve the recorded version. Neither equality nor mismatch is a content comparison or a synchronization-health verdict.
Local warnings cover malformed/self source declarations, invalid booleans, automatic creation without reflection permission, disabled sources with visible mirrors, and mirror chains whose updates are not propagated as ordinary source updates. Mirror details and Secret edit confirmation explain that local edits can persist until a source change overwrites them. Editing permissions and controls retain their existing behavior.
The README supported-resources table and integration documentation describe these surfaces and their limits.
Relationships and access
A shared metadata-only parser resolves explicit
reflectsannotations between observed same-kind core resources, including differently named mirrors. Resource topology adds a source-to-mirror Reflects to configuration edge. It implies no ownership or cascading deletion. Traffic topology is unchanged; Secret nodes remain hidden by default.The relationship response adds an optional
reflectionobject containing the observed source, its resource version, and visible mirrors. Existing configuration/consumer arrays remain available to API consumers; the drawer avoids duplicating reflection links in its generic Related Resources section. Existing shared UI consumers can render annotation details without injecting relationship data.Private relationship caches retain ConfigMaps/PVCs on large clusters and include Secrets. REST, MCP, and SSE remove unreadable namespaces, Secret endpoints, and cluster-scoped kinds before projection; callers receive cloned projections rather than mutations of the shared cache. SSE groups payloads by Secret grants. Source-version evidence comes from these already filtered nodes, with no additional object fetches or Secret contents.
Secret list authorization also applies to existing name-only Traefik/Contour TLS Secret stubs. Readers without that permission no longer see those stubs or incident edges.
Verification
Live checks used manually seeded annotations, not a running Reflector controller. Earlier restricted-identity tests covered raw detail/neighborhood filtering; this expansion adds a regression test for withholding source-version metadata.
Limits
Unavailable sources are not called missing, and visible mirror counts are not expected totals. Controller availability, name conflicts, absent automatic mirrors, destination eligibility, and synchronization lag require evidence beyond this integration. Reflector's installed version/configuration determines its namespace-rule behavior. No new controller watches, permissions, or mutation actions are added.
Repository documentation is included. A separate public docs-site navigation entry requires coordinated metadata in the radar-docs repository.
Note
Medium Risk
Touches shared topology caches, per-user relationship projection, and Secret visibility in SSE/API pathsâauthorization mistakes could leak metadata or hide legitimate edges.
Overview
Adds first-class EmberStack Reflector support for core ConfigMaps and Secrets across UI, topology, REST/MCP context, and docsâwithout new CRDs or controller watches.
Operator surfaces: ConfigMap/Secret drawers get Reflector summary banners and a collapsible section (source/mirror role, reflection settings, recorded
reflected-version/reflected-at, local config warnings). Mirrors link to authorized sources; Secret edits warn that local changes may be overwritten. Generic Related Resources no longer duplicate reflection links.Backend: A shared
configrefsparser resolvesreflectsannotations between observed same-kind objects. Topology gains Reflects to configuration edges; relationship APIs expose optionalreflection(source, mirrors, resource versions).resourceContext.reflectiononget_resource/REST AI context includes declared vs observed source, copy metadata, and up to 20 RBAC-filtered mirrors. Cross-namespace lookup usesReflectionLookupover the resource cache.Access & caching: Relationship topology is cloned and filtered per user (namespaces + Secret list RBAC) so shared caches are not mutated. SSE/MCP/REST strip unauthorized Secret nodes; relationship caches include Secrets and retain ConfigMaps/PVCs on large clusters for reflection edges.
Reviewed by Cursor Bugbot for commit 8630abf. Bugbot is set up for automated code reviews on this repo. Configure here.