hub v0.24.0: dispatcher routes critical severity (+ nil-prefs crash guard)

ProcessEvent routed only warning/error; a critical-severity event was silently dropped.
Now routes warning/error/critical, logs unrecognized severities, and guards a nil
GetNotificationPrefs (which would panic/crash the hub). host_disk_critical emits its
natural critical severity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HxLA1mZurFq9kt8hneFeCs
This commit is contained in:
2026-06-30 14:18:45 +02:00
parent 6882d853ed
commit 0ff1d3c883
6 changed files with 159 additions and 14 deletions
+3 -3
View File
@@ -167,9 +167,9 @@ func (dc *HostDiskChecker) emit(row store.HostDiskRow, oldBand, newBand string)
switch newBand {
case bandCritical:
eventType = "host_disk_critical"
// NB: the dispatcher only routes severity "warning"/"error" — a "critical" severity would be
// silently dropped — so the critical BAND maps to severity "error" (and the operator email's 🔴).
severity = "error"
// Natural "critical" severity (hub v0.24.0 routes it; the operator email styles it 🔴). Before
// v0.24.0 the dispatcher silently dropped "critical", so this had to be "error" — now it is honest.
severity = "critical"
message = fmt.Sprintf("Host %s: root filesystem CRITICALLY full at %.0f%% (threshold %.0f%%) — PVE/logging/agent writes may start failing; free space (e.g. old vzdump backups) immediately", row.HostID, row.DiskPercent, dc.crit)
case bandWarning:
eventType = "host_disk_warning"
+2 -2
View File
@@ -117,8 +117,8 @@ func TestHostDiskChecker_Severity(t *testing.T) {
dc.Check()
saveDiskReport(t, st, 97)
dc.Check()
if len(sev) != 2 || sev[0] != "warning" || sev[1] != "error" {
t.Fatalf("severities = %v, want [warning error] (critical band must be 'error' so the dispatcher routes it)", sev)
if len(sev) != 2 || sev[0] != "warning" || sev[1] != "critical" {
t.Fatalf("severities = %v, want [warning critical] (hub v0.24.0 routes the natural critical severity)", sev)
}
}