fix: Prometheus Metrics endpoint is always enabled because ha_proxy.stats_promex_enable is not checked properly#901
Open
fix: Prometheus Metrics endpoint is always enabled because ha_proxy.stats_promex_enable is not checked properly#901
Conversation
…rter if_p yields whenever a property has any value (including spec defaults), so the prometheus-exporter line was always emitted regardless of the property's boolean value. Switch to if p(...) to evaluate the boolean.
hoffmaen
approved these changes
Apr 21, 2026
Contributor
hoffmaen
left a comment
There was a problem hiding this comment.
Have you checked if the wrong use of if_p is also present in other places?
hoffmaen
reviewed
Apr 22, 2026
Contributor
There was a problem hiding this comment.
I've been poking around the code a bit, there is one more boolean property that suffers from the same bug: reload_idle_close_on_response.
Since it defaults to true, setting it to false still enters the if_p block and enables idle-close-on-response. Can you fix that too with this PR?
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.
if_pyields whenever a property has any value, including spec defaults — it does not check the boolean valueha_proxy.stats_promex_enablehasdefault: falsein the spec, soif_pwas always yielding and theprometheus-exporterline was always written to the rendered config, even when the property was never set by the operatorif_p(...)withif p(...)so the boolean is actually evaluatedThis has been the case since the feature was introduced in #536 so the prometheus metrics endpoint is currently active everywhere. Merging this PR would fix this but potentially break scenarios where people rely on it but haven't set the flag to
true.