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(truenas): retain emergency alerts in incident delivery
pulse-triage[bot]65a024b3d3f3
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 584c7ea8c5..efe6f0ad0c 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -17,7 +17,9 @@## Purpose-TrueNAS native alert projection preserves the trimmed, uppercase provider level in ResourceIncident.NativeSeverity. INFO and NOTICE retain the same canonical monitor risk; consumers must not lose their distinct actionability when projecting provider evidence.+TrueNAS native alert projection preserves the trimmed, uppercase provider level in ResourceIncident.NativeSeverity. INFO and NOTICE retain the same canonical monitor risk; consumers must not lose their distinct actionability when projecting provider evidence. Native CRITICAL, ALERT, and EMERGENCY all project to canonical critical severity; EMERGENCY must not be discarded as unknown or make a still-active condition appear recovered. WARNING remains warning, and INFO and NOTICE remain informational at this projection boundary.++Verification: `TestIncidentProjectionPreservesNativeSeverity` in `internal/truenas/provider_pool_health_contract_test.go` covers all seven native levels and case/whitespace normalization. `TestTrueNASNativeSeverityDispatch` in `internal/alerts/truenas_native_dispatch_test.go` verifies downstream INFO suppression, NOTICE preservation, notification severity, duplicate-poll retention, and confirmed recovery callback identity. The TrueNAS lifecycle tests in `internal/alerts/unified_incidents_test.go` require repeated EMERGENCY evidence to interrupt recovery confirmation. These are fixture-based projection and manager checks, not appliance ingestion or external notification-provider receipt proof.Unraid host ingestion and canonical read-state reconstruction preserve the optional array disk count, distinguishing explicit zero from unknown. Storage assessment suppresses only the no-parity warning for an explicit zero-disk array; unknown counts retain the prior warning and disabled, invalid, or missing member evidence remains effective.diff --git a/internal/alerts/truenas_native_dispatch_test.go b/internal/alerts/truenas_native_dispatch_test.gonew file mode 100644index 0000000000..826f482ad4--- /dev/null+++ b/internal/alerts/truenas_native_dispatch_test.go@@ -0,0 +1,92 @@+package alerts++import (+ "strings"+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/truenas"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+)++// Cover every documented TrueNAS severity through native projection and the+// manager's callback boundary. This does not claim external transport receipt.+func TestTrueNASNativeSeverityDispatch(t *testing.T) {+ for _, tc := range []struct {+ native string+ level AlertLevel+ }{+ {"INFO", ""},+ {"NOTICE", AlertLevelInfo},+ {"WARNING", AlertLevelWarning},+ {"ERROR", AlertLevelCritical},+ {"CRITICAL", AlertLevelCritical},+ {"ALERT", AlertLevelCritical},+ {"EMERGENCY", AlertLevelCritical},+ } {+ t.Run(tc.native, func(t *testing.T) {+ m := newTestManager(t)+ configureUnifiedEvalManager(t, m, unifiedEvalBaseConfig())+ var dispatched []Alert+ // Unified incident dispatch is synchronous; retain values, not live pointers.+ m.SetAlertCallback(func(alert *Alert) { dispatched = append(dispatched, *alert) })+ resolved := make(chan string, 4)+ m.SetResolvedCallback(func(id string) { resolved <- id })+ project := func(level string) []unifiedresources.Resource {+ records := truenas.FixtureRecords(truenas.FixtureSnapshot{+ CollectedAt: time.Now(),+ System: truenas.SystemInfo{Hostname: "native-dispatch", 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)+ }+ return resources+ }+ resources := project(" " + strings.ToLower(tc.native) + " ")+ m.SyncUnifiedResourceIncidents(resources)+ m.SyncUnifiedResourceIncidents(resources)+ want := 1+ if tc.level == "" {+ want = 0+ }+ if len(dispatched) != want || len(m.GetActiveAlerts()) != want {+ t.Fatalf("dispatches/active = %d/%d, want %d/%d", len(dispatched), len(m.GetActiveAlerts()), want, want)+ }+ if want == 0 {+ return+ }+ if dispatched[0].Level != tc.level {+ t.Fatalf("dispatched severity = %s, want %s", dispatched[0].Level, tc.level)+ }+ // Missing telemetry cannot resolve a native incident.+ m.SyncUnifiedResourceIncidents(nil)+ m.SyncUnifiedResourceIncidents(nil)+ if len(m.GetActiveAlerts()) != 1 {+ t.Fatal("missing telemetry resolved incident")+ }+ information := project("INFO")+ m.SyncUnifiedResourceIncidents(information)+ if len(m.GetActiveAlerts()) != 1 {+ t.Fatal("single recovery observation resolved incident")+ }+ m.SyncUnifiedResourceIncidents(information)+ if len(m.GetActiveAlerts()) != 0 {+ t.Fatal("confirmed recovery retained incident")+ }+ select {+ case id := <-resolved:+ if id != dispatched[0].ID {+ t.Fatalf("resolved ID = %s, want %s", id, dispatched[0].ID)+ }+ case <-time.After(2 * time.Second):+ t.Fatal("missing resolution callback")+ }+ if len(dispatched) != 1 {+ t.Fatal("INFO recovery dispatched an alert")+ }+ })+ }+}diff --git a/internal/alerts/unified_incidents_test.go b/internal/alerts/unified_incidents_test.goindex fe66c1416f..7eb2b75d3a 100644--- a/internal/alerts/unified_incidents_test.go+++ b/internal/alerts/unified_incidents_test.go@@ -1220,6 +1220,8 @@ func TestSyncUnifiedResourceIncidentsTrueNASNativeRecoveryStreak(t *testing.T) {{"NOTICE", AlertLevelInfo, 1},{"WARNING", AlertLevelWarning, 1},{"CRITICAL", AlertLevelCritical, 1},+ {"EMERGENCY", AlertLevelCritical, 1},+ {"EMERGENCY", AlertLevelCritical, 1},{"INFO", AlertLevelCritical, 1},{"WARNING", AlertLevelWarning, 1},{"INFO", AlertLevelWarning, 1},diff --git a/internal/truenas/provider.go b/internal/truenas/provider.goindex 427f85148c..f1634a8692 100644--- a/internal/truenas/provider.go+++ b/internal/truenas/provider.go@@ -1582,7 +1582,7 @@ func appIncidentKey(app App) string {func severityFromAlertLevel(level string) (storagehealth.RiskLevel, bool) {switch strings.ToUpper(strings.TrimSpace(level)) {- case "CRITICAL", "ERROR", "ALERT":+ case "CRITICAL", "ERROR", "ALERT", "EMERGENCY":return storagehealth.RiskCritical, truecase "WARNING", "WARN":return storagehealth.RiskWarning, truediff --git a/internal/truenas/provider_pool_health_contract_test.go b/internal/truenas/provider_pool_health_contract_test.goindex ce99afcc01..a10e011b28 100644--- a/internal/truenas/provider_pool_health_contract_test.go+++ b/internal/truenas/provider_pool_health_contract_test.go@@ -254,17 +254,28 @@ func TestPoolTopologyStaysDiscriminatorAcrossVDevLayouts(t *testing.T) {}func TestIncidentProjectionPreservesNativeSeverity(t *testing.T) {- for _, level := range []string{"INFO", "NOTICE"} {- t.Run(level, func(t *testing.T) {- incident, ok := incidentFromAlert(Alert{ID: "condition-1", Level: " " + strings.ToLower(level) + " ", Message: "Provider condition"})+ for _, tc := range []struct {+ level string+ severity storagehealth.RiskLevel+ }{+ {"INFO", storagehealth.RiskMonitor},+ {"NOTICE", storagehealth.RiskMonitor},+ {"WARNING", storagehealth.RiskWarning},+ {"ERROR", storagehealth.RiskCritical},+ {"CRITICAL", storagehealth.RiskCritical},+ {"ALERT", storagehealth.RiskCritical},+ {"EMERGENCY", storagehealth.RiskCritical},+ } {+ t.Run(tc.level, func(t *testing.T) {+ incident, ok := incidentFromAlert(Alert{ID: "condition-1", Level: " " + strings.ToLower(tc.level) + " ", Message: "Provider condition"})if !ok {t.Fatal("native condition omitted")}- if incident.NativeSeverity != level {- t.Fatalf("native severity = %q, want %q", incident.NativeSeverity, level)+ if incident.NativeSeverity != tc.level {+ t.Fatalf("native severity = %q, want %q", incident.NativeSeverity, tc.level)}- if incident.Severity != storagehealth.RiskMonitor {- t.Fatalf("canonical severity inflated: %v", incident.Severity)+ if incident.Severity != tc.severity {+ t.Fatalf("canonical severity = %v, want %v", incident.Severity, tc.severity)}if incident.NativeID != "condition-1" {t.Fatalf("native identity changed: %q", incident.NativeID)