From ce6a76a0f99bdbafca44056d60d186239ecb975c Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Wed, 10 Sep 2025 15:12:43 +0000 Subject: [PATCH] fix: preserve PBS alert thresholds when updating node configuration (addresses #440) When updating PBS nodes through the node configuration UI, alert thresholds were being reset to defaults. This was because alert overrides are stored separately from node configuration and weren't being preserved during node updates. The fix ensures that when a node is updated, the alert configuration (including any custom threshold overrides) is reloaded and preserved. This applies to both PBS and PVE nodes to ensure consistent behavior. --- internal/api/config_handlers.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.go index 2b056784c..020d5e794 100644 --- a/internal/api/config_handlers.go +++ b/internal/api/config_handlers.go @@ -1045,6 +1045,7 @@ func (h *ConfigHandlers) HandleUpdateNode(w http.ResponseWriter, r *http.Request http.Error(w, "Invalid node ID", http.StatusBadRequest) return } + // Update the node if nodeType == "pve" && index < len(h.config.PVEInstances) { @@ -1145,6 +1146,26 @@ func (h *ConfigHandlers) HandleUpdateNode(w http.ResponseWriter, r *http.Request http.Error(w, "Failed to save configuration", http.StatusInternalServerError) return } + + // IMPORTANT: Preserve alert overrides when updating nodes + // This fixes issue #440 where PBS alert thresholds were being reset + // Alert overrides are stored separately from node configuration + // and must be explicitly preserved during node updates + if h.monitor != nil { + // 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 + h.monitor.GetAlertManager().UpdateConfig(*alertConfig) + log.Debug(). + Str("nodeID", nodeID). + Str("nodeType", nodeType). + Msg("Preserved alert overrides after node update") + } + } // Reload monitor with new configuration if h.reloadFunc != nil {