hub v0.117.0: the status follows the configured threshold; slow crash loop and interrupted restore events
gates / gates (push) Successful in 21s

R-549 (operator ruling A): controllerStatus hardcoded 30m/1h while both
staleness checkers and hostStatus read alerting.stale_threshold. Moving the
threshold to 45m would have painted a customer amber 15 minutes before the
alarm could fire - the second definition rollup.go's header forbids. It now
reads the same value, down at 2x. Both 'checker initialized' log lines print
the threshold, which no line did before.

R-539 (ruling 3 of 2026-09-16): controller_slow_crashloop (warning,
operator-only), minted when the agent's slow_crashloop_since moves, with the
fast sibling's first-sight rule.

R-550: restore_interrupted (warning, for the household) allowlisted with a
Hungarian customer message.

Red-proofs, each seen failing then passing: the status test with the old
hardcoded numbers; the checker test with the movement branch removed; the
operator-only test with the registration removed; the household-message test
with the Hungarian entry removed (asserted on the SUBJECT - the body
legitimately repeats the raw message, which my first version of the test
mistook for a fallback).

go build/vet/test ./... green, 18 packages.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-17 10:20:32 +02:00
1 parent 469bfa5d56
commit 37ae31fd44
15 files changed
+210 -15

No files matched your search

+23 -4
View File
@@ -15,7 +15,10 @@ import (
// rides the host report as `controller_supervisor`, and this checker turns movement in it into events:
//
// - `controller_restarted_by_agent` (info) when a guest's last_restart_at MOVES to a new value;
// - `controller_crashloop` (error, operator-only) when a guest's crashloop_since MOVES.
// - `controller_crashloop` (error, operator-only) when a guest's crashloop_since MOVES;
// - `controller_slow_crashloop` (warning, operator-only) when a guest's slow_crashloop_since MOVES
// (R-539, operator ruling 3 of 2026-09-16, agent v0.132.0): five restarts inside 24 hours, the
// loop the 15-minute brake cannot see because each restart falls outside its window.
//
// TIMESTAMPS, NOT COUNTERS. The agent's record is in-memory, so an agent restart zeroes
// restarts_total; keying on a counter would read that as nothing (fine) but a later 1 would not
@@ -36,8 +39,9 @@ type ControllerSupervisorChecker struct {
}
type supSeen struct {
lastRestartAt string
crashloopSince string
lastRestartAt string
crashloopSince string
slowCrashloopSince string
}
// ControllerSupervisorGuest mirrors the agent's hub.ControllerSupervisorGuest wire shape.
@@ -49,6 +53,10 @@ type ControllerSupervisorGuest struct {
Crashloop bool `json:"crashloop"`
CrashloopSince string `json:"crashloop_since"`
Parked bool `json:"parked"`
// R-539 (agent v0.132.0). Absent on older agents → zero values → never an event.
Restarts24h int `json:"restarts_24h"`
SlowCrashloop bool `json:"slow_crashloop"`
SlowCrashloopSince string `json:"slow_crashloop_since"`
}
// ParseControllerSupervisor extracts the stanza from a host report body. A missing or malformed
@@ -90,11 +98,14 @@ func (c *ControllerSupervisorChecker) observe(hostID, customerID string, guests
for _, g := range guests {
key := fmt.Sprintf("%s/%d", hostID, g.VMID)
prev, known := c.seen[key]
c.seen[key] = supSeen{lastRestartAt: g.LastRestartAt, crashloopSince: g.CrashloopSince}
c.seen[key] = supSeen{lastRestartAt: g.LastRestartAt, crashloopSince: g.CrashloopSince, slowCrashloopSince: g.SlowCrashloopSince}
if !known {
if g.Crashloop && g.CrashloopSince != "" {
c.emit(customerID, hostID, g, "controller_crashloop")
}
if g.SlowCrashloop && g.SlowCrashloopSince != "" {
c.emit(customerID, hostID, g, "controller_slow_crashloop")
}
continue
}
if g.LastRestartAt != "" && g.LastRestartAt != prev.lastRestartAt {
@@ -103,6 +114,9 @@ func (c *ControllerSupervisorChecker) observe(hostID, customerID string, guests
if g.CrashloopSince != "" && g.CrashloopSince != prev.crashloopSince {
c.emit(customerID, hostID, g, "controller_crashloop")
}
if g.SlowCrashloopSince != "" && g.SlowCrashloopSince != prev.slowCrashloopSince {
c.emit(customerID, hostID, g, "controller_slow_crashloop")
}
}
}
@@ -117,6 +131,10 @@ func (c *ControllerSupervisorChecker) emit(customerID, hostID string, g Controll
severity = "error"
message = fmt.Sprintf("Host %s guest %d: the controller will not stay up — the agent stopped restarting it after repeated attempts (since %s) and will try again in 30 minutes. Last reason: %s",
hostID, g.VMID, g.CrashloopSince, g.LastReason)
case "controller_slow_crashloop":
severity = "warning"
message = fmt.Sprintf("Host %s guest %d: the controller keeps dying — the agent restarted it %d times in 24 hours (each one too far apart for the 15-minute brake). It is still being restarted; this is the warning that it will not stay up. Last reason: %s",
hostID, g.VMID, g.Restarts24h, g.LastReason)
default:
return
}
@@ -124,6 +142,7 @@ func (c *ControllerSupervisorChecker) emit(customerID, hostID string, g Controll
"host_id": hostID, "vmid": g.VMID, "restarts_total": g.RestartsTotal,
"last_restart_at": g.LastRestartAt, "last_reason": g.LastReason,
"crashloop_since": g.CrashloopSince, "parked": g.Parked,
"restarts_24h": g.Restarts24h, "slow_crashloop_since": g.SlowCrashloopSince,
})
c.logger.Printf("[INFO] Controller supervisor: %s %s/%d (%s)", eventType, hostID, g.VMID, g.LastReason)
if _, err := c.store.SaveEvent(customerID, eventType, severity, message, string(details), "hub"); err != nil {