Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

fix(alerts): notify when provider incidents become critical

pulse-triage[bot]4752d5b4b7f0
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index bb592212ca..fd045bd6ce 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -20,6 +20,15 @@ enter the actionable active-alert lifecycle. Native NOTICE remains actionable
at informational canonical severity; it must not be discarded merely because
INFO and NOTICE share the monitor risk level. Native severity is preserved by
the provider projection.
+An existing provider incident transitioning from a non-critical level to
+critical re-enters canonical notification dispatch, subject to acknowledgement,
+rate limits, and delivery policy. The transition preserves incident identity
+and start time. Repeated critical observations and severity downgrades do not
+re-notify; confirmed recovery retains the same lifecycle identity.
+`TestTrueNASNativeCriticalTransition` in
+`internal/alerts/unified_incidents_test.go` verifies these boundaries through
+native TrueNAS WARNING, EMERGENCY, and INFO observations.
+
Warning and critical incidents retain normal routing; downgrade to information
clears an existing actionable incident through normal synchronisation.
`TestSyncUnifiedResourceIncidentsTrueNASInformation` in
diff --git a/internal/alerts/unified_incidents.go b/internal/alerts/unified_incidents.go
index 93e1aabe67..4130235da4 100644
--- a/internal/alerts/unified_incidents.go
+++ b/internal/alerts/unified_incidents.go
@@ -254,6 +254,7 @@ func (m *Manager) SyncUnifiedResourceIncidents(resources []unifiedresources.Reso
for storageKey, alert := range desired {
if existing, exists := m.getActiveAlertNoLock(storageKey); exists && existing != nil {
+ oldLevel := existing.Level
existing.LastSeen = alert.LastSeen
existing.Level = alert.Level
existing.ResourceID = alert.ResourceID
@@ -281,6 +282,14 @@ func (m *Manager) SyncUnifiedResourceIncidents(resources []unifiedresources.Reso
}
applyCanonicalIdentity(existing, alert.CanonicalSpecID, alert.CanonicalKind)
m.setActiveAlertNoLock(storageKey, existing)
+ // Like metric alerts, an existing provider incident becoming critical
+ // must notify again. Keep its lifecycle and all delivery policy gates;
+ // unchanged severity and downgrades must not create notification noise.
+ if oldLevel != existing.Level && existing.Level == AlertLevelCritical &&
+ !existing.Acknowledged &&
+ m.allowNotificationByRateLimit(storageKey, existing, "critical-escalation") {
+ m.dispatchAlert(existing, false)
+ }
continue
}
diff --git a/internal/alerts/unified_incidents_test.go b/internal/alerts/unified_incidents_test.go
index 7eb2b75d3a..d0691cc5e9 100644
--- a/internal/alerts/unified_incidents_test.go
+++ b/internal/alerts/unified_incidents_test.go
@@ -1253,3 +1253,76 @@ func TestSyncUnifiedResourceIncidentsTrueNASNativeRecoveryStreak(t *testing.T) {
}
}
}
+
+// A severity change must retain the incident identity without silently losing
+// the critical notification or dispatching on every subsequent observation.
+func TestTrueNASNativeCriticalTransition(t *testing.T) {
+ for _, acknowledged := range []bool{false, true} {
+ t.Run(map[bool]string{false: "active", true: "acknowledged"}[acknowledged], func(t *testing.T) {
+ m := newTestManager(t)
+ configureUnifiedEvalManager(t, m, unifiedEvalBaseConfig())
+ var dispatched []Alert
+ m.SetAlertCallback(func(a *Alert) { dispatched = append(dispatched, *a) })
+ resolved := make(chan string, 4)
+ m.SetResolvedCallback(func(id string) { resolved <- id })
+ syncLevel := func(level string) {
+ records := truenas.FixtureRecords(truenas.FixtureSnapshot{
+ CollectedAt: time.Now(),
+ System: truenas.SystemInfo{Hostname: "native-transition", Healthy: true},
+ Alerts: []truenas.Alert{{ID: "native-1", Level: level, Message: "Provider condition"}},
+ })
+ var resources []unifiedresources.Resource
+ for _, record := range records {
+ record.Resource.ID = "host:" + record.SourceID
+ resources = append(resources, record.Resource)
+ }
+ m.SyncUnifiedResourceIncidents(resources)
+ }
+ syncLevel("WARNING")
+ if len(dispatched) != 1 {
+ t.Fatalf("initial dispatches = %d", len(dispatched))
+ }
+ initial := dispatched[0]
+ if acknowledged {
+ m.mu.Lock()
+ for _, a := range m.activeAlerts {
+ a.Acknowledged = true
+ }
+ m.mu.Unlock()
+ }
+ syncLevel("EMERGENCY")
+ syncLevel("EMERGENCY")
+ active := m.GetActiveAlerts()
+ if len(active) != 1 || active[0].ID != initial.ID || active[0].Level != AlertLevelCritical || !active[0].StartTime.Equal(initial.StartTime) {
+ t.Fatalf("critical transition lost lifecycle identity: %+v", active)
+ }
+ want := 2
+ if acknowledged {
+ want = 1
+ }
+ if len(dispatched) != want {
+ t.Fatalf("dispatches = %d, want %d", len(dispatched), want)
+ }
+ if !acknowledged && (dispatched[1].ID != initial.ID || dispatched[1].Level != AlertLevelCritical) {
+ t.Fatal("critical notification lost severity or identity")
+ }
+ syncLevel("WARNING")
+ if len(dispatched) != want {
+ t.Fatal("downgrade dispatched")
+ }
+ syncLevel("INFO")
+ syncLevel("INFO")
+ if len(m.GetActiveAlerts()) != 0 {
+ t.Fatal("confirmed recovery retained incident")
+ }
+ select {
+ case id := <-resolved:
+ if id != initial.ID {
+ t.Fatalf("recovery ID = %s, want %s", id, initial.ID)
+ }
+ case <-time.After(2 * time.Second):
+ t.Fatal("missing recovery callback")
+ }
+ })
+ }
+}