Skip to content

fix(base-cluster/monitoring): otherwise the metric will be duplicated if suspend is not set#1661

Merged
cwrau merged 1 commit intomainfrom
fix/base-cluster/kube-state-metrics-flux-suspended-gauge-duplicates
Sep 2, 2025
Merged

fix(base-cluster/monitoring): otherwise the metric will be duplicated if suspend is not set#1661
cwrau merged 1 commit intomainfrom
fix/base-cluster/kube-state-metrics-flux-suspended-gauge-duplicates

Conversation

@cwrau
Copy link
Copy Markdown
Member

@cwrau cwrau commented Sep 2, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the reconcile_suspended gauge to read directly from spec.suspend, ensuring accurate status reporting for suspended custom resources.
    • Resolves misreported values in monitoring, reducing false positives/negatives in dashboards and alerts.
    • Improves reliability of metrics consumed by kube-prometheus-stack visualizations and alerting rules.

Copilot AI review requested due to automatic review settings September 2, 2025 09:21
@cwrau cwrau enabled auto-merge September 2, 2025 09:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 2, 2025

Walkthrough

Adjusted kube-state-metrics customResourceState configuration: reconcile_suspended_gauge now reads directly from spec.suspend by changing path to ["spec","suspend"] and removing valueFrom. Gauge type and nilIsZero remain unchanged. No other files or entities modified.

Changes

Cohort / File(s) Summary
kube-state-metrics config
charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml
Change reconcile_suspended_gauge path from ["spec"] with valueFrom ["suspend"] to ["spec","suspend"]; keep type "Gauge" and nilIsZero: true

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

base-cluster

Suggested reviewers

  • marvinWolff
  • teutonet-bot
  • tasches

Poem

A hop, a skip, a tidy tweak,
From spec to suspend we swiftly peek.
Gauges aligned, no detours found,
Nil is zero, metrics sound.
Thump-thump—my paws approve this fix,
Carrots counted: one, two, six! 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a1a8924 and 23609ec.

📒 Files selected for processing (1)
  • charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Update release-please config file for a possibly new chart
  • GitHub Check: check licenses
  • GitHub Check: lint helm chart (base-cluster)
🔇 Additional comments (1)
charts/base-cluster/templates/monitoring/kube-prometheus-stack/_kube-state-metrics-config.yaml (1)

88-90: Directly reading spec.suspend is the right fix to prevent duplicates.

Switching to path ["spec","suspend"] (and keeping nilIsZero: true) avoids emitting multiple series when suspend is unset, and still yields 0/1 for boolean values. Looks good.

Quick checks to run after rollout:

  • PromQL: Ensure no duplicate time series per object
    • count by (job, customresource_namespace, customresource_name) (gotk_reconcile_suspended_gauge) > 1
    • max_over_time(gotk_reconcile_suspended_gauge[5m]) to confirm 0/1 behavior across objects with/without suspend set.
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/base-cluster/kube-state-metrics-flux-suspended-gauge-duplicates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a configuration issue in the kube-state-metrics setup where metrics could be duplicated when the suspend field is not set. The fix consolidates the path specification for accessing the suspend field in Kubernetes custom resources.

  • Simplifies the path configuration for the suspend field metric
  • Prevents metric duplication by using a single consolidated path instead of separate path and valueFrom specifications

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cwrau cwrau added this pull request to the merge queue Sep 2, 2025
Merged via the queue into main with commit 193c6b3 Sep 2, 2025
35 checks passed
@cwrau cwrau deleted the fix/base-cluster/kube-state-metrics-flux-suspended-gauge-duplicates branch September 2, 2025 10:06
github-merge-queue Bot pushed a commit that referenced this pull request Sep 2, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.3.2](base-cluster-v9.3.1...base-cluster-v9.3.2)
(2025-09-02)


### Bug Fixes

* **base-cluster/monitoring:** otherwise the metric will be duplicated
if `suspend` is not set
([#1661](#1661))
([193c6b3](193c6b3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* Bug Fixes
* Prevents duplicate monitoring metrics when “suspend” is not set in the
base-cluster chart.
* Documentation
* Added changelog entry for version 9.3.2 with details of the metrics
duplication fix.
* Chores
* Updated base-cluster chart to version 9.3.2 in release configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants