Skip to content

[fix] resolve {PREFIX} metric init order in module_manager#760

Merged
ipaqsa merged 2 commits intomainfrom
fix/metric-prefix-replacement-init-order
May 5, 2026
Merged

[fix] resolve {PREFIX} metric init order in module_manager#760
ipaqsa merged 2 commits intomainfrom
fix/metric-prefix-replacement-init-order

Conversation

@diyliv
Copy link
Copy Markdown
Contributor

@diyliv diyliv commented May 5, 2026

Overview

Fix {PREFIX} placeholder not being replaced in two addon-operator metrics (mm_module_info and mm_module_maintenance), causing them to appear as _PREFIX_mm_* in Prometheus instead of deckhouse_mm_*.

What this PR does / why we need it

Package-level variables moduleInfoMetricName and moduleMaintenanceMetricName in module_manager.go copied metric names from the metrics package at Go init time, before InitMetrics() could replace the {PREFIX} placeholder. At call sites, these stale copies were used instead of the updated metrics.ModuleInfoMetricName / metrics.ModuleMaintenanceMetricName.

This caused the ModuleIsInMaintenanceMode Prometheus alert to never fire, because the alert expression referenced deckhouse_mm_module_maintenance while the actual metric was exported as _PREFIX_mm_module_maintenance.

The fix removes the two package-level variable copies and reads directly from metrics.ModuleInfoMetricName / metrics.ModuleMaintenanceMetricName at call time, after InitMetrics() has already replaced the prefix.

Special notes for your reviewer

Verified in a staging Deckhouse cluster — before the fix, only _PREFIX_mm_module_maintenance and _PREFIX_mm_module_info were present; all other metrics correctly used the deckhouse_ prefix.

Signed-off-by: diyliv <onlogn081@gmail.com>
@diyliv diyliv added bug Something isn't working labels May 5, 2026
Signed-off-by: diyliv <onlogn081@gmail.com>
@ipaqsa ipaqsa self-requested a review May 5, 2026 11:12
@ipaqsa ipaqsa added go Pull requests that update Go code release-note/bug Something isn't working labels May 5, 2026
@ipaqsa ipaqsa merged commit cd6c54c into main May 5, 2026
14 of 15 checks passed
@ldmonster ldmonster deleted the fix/metric-prefix-replacement-init-order branch May 5, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code release-note/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants