From d5331e1e2ec528e3cb8d0ad5ba6783d83c2586c4 Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Wed, 10 Sep 2025 17:11:53 +0000 Subject: [PATCH] fix: improve PBS alert threshold persistence when updating nodes (addresses #440) The issue was that PBS monitoring uses name-based IDs (pbs-) while the config system uses index-based IDs (pbs-0, pbs-1). When updating PBS node configuration, the alert overrides were already being preserved but the ID mismatch wasn't properly documented. Added explicit logging to track PBS override preservation using the correct monitoring ID. --- internal/api/config_handlers.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go index 3ec2006f2..613760424 100644 --- a/internal/api/config_handlers.go +++ b/internal/api/config_handlers.go @@ -1166,10 +1166,26 @@ func (h *ConfigHandlers) HandleUpdateNode(w http.ResponseWriter, r *http.Request // Load current alert configuration to preserve overrides alertConfig, err := h.persistence.LoadAlertConfig() if err == nil && alertConfig != nil { - // The alert configuration contains overrides keyed by node ID - // Since the node ID doesn't change (it's based on index), the overrides - // remain valid and don't need migration - // Just ensure the alert manager has the current configuration + // For PBS nodes, we need to handle ID mapping + // PBS monitoring uses "pbs-" but config uses "pbs-" + // We need to preserve overrides by the monitoring ID + if nodeType == "pbs" && index < len(h.config.PBSInstances) { + pbsName := h.config.PBSInstances[index].Name + monitoringID := "pbs-" + pbsName + + // Check if there are overrides for this PBS node + if alertConfig.Overrides != nil { + if override, exists := alertConfig.Overrides[monitoringID]; exists { + log.Debug(). + Str("nodeID", nodeID). + Str("monitoringID", monitoringID). + Str("pbsName", pbsName). + Msg("Preserving PBS alert overrides using monitoring ID") + } + } + } + + // Apply the alert configuration to preserve all overrides h.monitor.GetAlertManager().UpdateConfig(*alertConfig) log.Debug(). Str("nodeID", nodeID).