Skip to content

Fix ConfigMap analyzer false positives for operator-managed sidecars#1605

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/review-pr-1602
Draft

Fix ConfigMap analyzer false positives for operator-managed sidecars#1605
Copilot wants to merge 3 commits intomainfrom
copilot/review-pr-1602

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 30, 2026

📑 Description

ConfigMap analyzer flags operator-managed ConfigMaps as unused because sidecars load them dynamically via label selectors rather than Pod spec references. Affects Grafana dashboards, Prometheus rules, and similar patterns.

Changes:

  • Added sidecar pattern detection via labels: grafana_dashboard, grafana_datasource, prometheus_rule, fluentd_config
  • Added k8sgpt.ai/dynamically-loaded: "true" label for custom patterns
  • Added k8sgpt.ai/skip-usage-check: "true" annotation for explicit opt-out
  • Matched ConfigMaps skip all analyzer checks (unused, empty, large)

Implementation:

// New helper functions in configmap.go
func isKnownSidecarPattern(cm v1.ConfigMap) bool {
    // Checks for grafana_dashboard, prometheus_rule, etc.
}

func shouldSkipUsageCheck(cm v1.ConfigMap) bool {
    // Checks k8sgpt.ai/skip-usage-check annotation
}

Analyzer now checks these patterns before flagging ConfigMaps, preserving existing detection logic for standard usage.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

Validated against kube-prometheus-stack: eliminated 29 false positives (28 dashboard + 1 datasource ConfigMaps). Backward compatible - no changes to existing detection behavior.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 30, 2026 16:52
Co-authored-by: AlexsJones <1235925+AlexsJones@users.noreply.github.com>
Co-authored-by: AlexsJones <1235925+AlexsJones@users.noreply.github.com>
Copilot AI changed the title [WIP] Review pull request 1602 for changes Fix ConfigMap analyzer false positives for operator-managed sidecars Jan 30, 2026
Copilot AI requested a review from AlexsJones January 30, 2026 17:01
@AlexsJones AlexsJones added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Proposed

Development

Successfully merging this pull request may close these issues.

2 participants