Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix: Preserve ackState for old acknowledged alerts during restore
rcourtman48fdff3efbc1
diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.goindex 37ddb50b23..201ed06495 100644--- a/internal/alerts/alerts.go+++ b/internal/alerts/alerts.go@@ -8726,9 +8726,20 @@ func (m *Manager) LoadActiveAlerts() error {continue}- // Skip acknowledged alerts older than 1 hour+ // Skip acknowledged alerts older than 1 hour from activeAlerts,+ // but still preserve the ackState so if the same alert reappears+ // (e.g., backup-age alerts) it won't retrigger notifications.if alert.Acknowledged && alert.AckTime != nil && now.Sub(*alert.AckTime) > time.Hour {- log.Debug().Str("alertID", alert.ID).Msg("Skipping old acknowledged alert")+ log.Debug().Str("alertID", alert.ID).Msg("Skipping old acknowledged alert from activeAlerts but preserving ackState")+ ackTime := alert.StartTime+ if alert.AckTime != nil {+ ackTime = *alert.AckTime+ }+ m.ackState[alert.ID] = ackRecord{+ acknowledged: true,+ user: alert.AckUser,+ time: ackTime,+ }continue}diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex 00b18add19..ca262867a1 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -15343,10 +15343,22 @@ func TestLoadActiveAlerts(t *testing.T) {m.mu.RLock()_, exists := m.activeAlerts["old-ack-alert"]+ ackRecord, ackExists := m.ackState["old-ack-alert"]m.mu.RUnlock()if exists {- t.Error("old acknowledged alert (>1h) should be skipped during load")+ t.Error("old acknowledged alert (>1h) should be skipped from activeAlerts")+ }++ // But ackState should be preserved so the alert doesn't retrigger if it reappears+ if !ackExists {+ t.Error("ackState should be preserved for old acknowledged alerts to prevent retriggering")+ }+ if ackExists && !ackRecord.acknowledged {+ t.Error("ackState.acknowledged should be true")+ }+ if ackExists && ackRecord.user != "testuser" {+ t.Errorf("ackState.user should be 'testuser', got %q", ackRecord.user)}})