Fix inconsistent guards for scale set metrics registration and publishing#4566
Open
Okabe-Junya wants to merge 1 commit into
Open
Fix inconsistent guards for scale set metrics registration and publishing#4566Okabe-Junya wants to merge 1 commit into
Okabe-Junya wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes how the controller decides whether scale set metrics are enabled by introducing a single metricsEnabled boolean derived from metricsAddr, and reusing it consistently for both metrics registration and metrics publishing.
Changes:
- Add a shared
metricsEnabled := metricsAddr != "" && metricsAddr != "0"condition to represent “metrics enabled”. - Guard
actionsgithubcommetrics.RegisterMetrics()andEphemeralRunnerSetReconciler.PublishMetricswith the same condition to avoid inconsistent behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Introduce a single
metricsEnabledcondition (metricsAddr != "" && metricsAddr != "0") and use it for both:actionsgithubcommetrics.RegisterMetrics()(previously guarded bymetricsAddr != "")EphemeralRunnerSetReconciler.PublishMetrics(previouslymetricsAddr != "0")Why
Registration was guarded by
metricsAddr != ""while publishing was guarded bymetricsAddr != "0", so the two could disagree.controller-runtime treats "0" - not "" - as the token to disable its metrics server.
Options.BindAddress documents "Set this to 0 to disable the metrics server", and NewServer returns nil when
BindAddress == "0". FYI:https://github.com/kubernetes-sigs/controller-runtime/blob/3be3f1bf2b2fcc6b5c9510d55c6a9972294653d0/pkg/metrics/server/server.go#L119-L122
The Helm chart accordingly passes
--metrics-addr=0when metrics are disabled.With
metricsAddr="", the old guards skipped registration but still published: the reconciler keeps callingWithLabelValues().Set()on an unregistered GaugeVec, accumulating per-label child metrics in memory until restart while nothing is ever scraped.Aligning both guards on one metricsEnabled condition treats "" and "0" consistently as "metrics disabled"