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.

Keep offline agents removable after restart

rcourtmanf3bfc7c72a3d
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 99d0976276..366c37005d 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -1297,7 +1297,11 @@ That same continuity rule applies to canonical unified resource snapshots.
continuity records onto `UnifiedResourceSnapshot()` and
`GetUnifiedReadStateOrSnapshot()` results, so first-login and post-restart
Infrastructure views retain the durable agent-backed systems Pulse already
-knows about while live reports and supplemental providers catch up.
+knows about while live reports and supplemental providers catch up. A host
+projected only from durable continuity has no current report in that monitor
+generation and must therefore render offline while preserving its last-known
+identity and removal action; persisted telemetry must never manufacture an
+online sighting after restart.
That same monitoring owner also governs collector payload compatibility at the
shared boundary. Podman container stats must honor Podman's compat payload when
it exposes a direct CPU percentage and otherwise fall back to Podman's
diff --git a/internal/monitoring/monitor_host_agent_removal_lifecycle_test.go b/internal/monitoring/monitor_host_agent_removal_lifecycle_test.go
index 9c26f0a125..da65156347 100644
--- a/internal/monitoring/monitor_host_agent_removal_lifecycle_test.go
+++ b/internal/monitoring/monitor_host_agent_removal_lifecycle_test.go
@@ -297,6 +297,64 @@ func TestHostAgentRemovalLifecycleSurvivesMonitorReconstruction(t *testing.T) {
}
}
+func TestHostAgentRemovalLifecycleKeepsOfflineRowRemovableAfterRestart(t *testing.T) {
+ dataPath := t.TempDir()
+ now := time.Now().UTC()
+ token := &config.APITokenRecord{
+ ID: "offline-restart-token",
+ CreatedAt: now.Add(-time.Hour),
+ }
+ report := hostRemovalLifecycleReport(
+ "offline-restart-machine",
+ "offline-restart-machine",
+ "offline-restart-agent",
+ "offline-restart.local",
+ "linux",
+ now,
+ )
+
+ first := newHostRemovalLifecycleMonitor(t, dataPath)
+ host, err := first.ApplyHostReport(report, token)
+ if err != nil {
+ t.Fatalf("initial ApplyHostReport: %v", err)
+ }
+
+ // Reconstruct the monitor without another agent report. The durable row
+ // must remain visible as offline so its removal action stays reachable.
+ restarted := newHostRemovalLifecycleMonitor(t, dataPath)
+ hosts := restarted.HostsSnapshot()
+ if len(hosts) != 1 || hosts[0].ID != host.ID {
+ t.Fatalf("restart host inventory = %+v, want continuity row %q", hosts, host.ID)
+ }
+ if hosts[0].Status != "offline" {
+ t.Fatalf("restart continuity status = %q, want offline", hosts[0].Status)
+ }
+
+ for i := 0; i < 3; i++ {
+ restarted.evaluateHostAgents(now.Add(10*time.Minute + time.Duration(i)*time.Second))
+ }
+ if alerts := restarted.alertManager.GetActiveAlerts(); len(alerts) != 1 || alerts[0].Type != "host-offline" {
+ t.Fatalf("restart offline alerts = %+v, want one host-offline alert", alerts)
+ }
+
+ removed, err := restarted.RemoveHostAgent(host.ID)
+ if err != nil {
+ t.Fatalf("RemoveHostAgent after restart: %v", err)
+ }
+ if removed.ID != host.ID || removed.Hostname != host.Hostname {
+ t.Fatalf("removed continuity host = %+v, want %+v", removed, host)
+ }
+ if hosts := restarted.HostsSnapshot(); len(hosts) != 0 {
+ t.Fatalf("removed host remained visible after restart: %+v", hosts)
+ }
+ if alerts := restarted.alertManager.GetActiveAlerts(); len(alerts) != 0 {
+ t.Fatalf("removed host alerts remained active: %+v", alerts)
+ }
+ if tombstones := restarted.hostContinuityStore.RemovedEntries(); len(tombstones) != 1 || tombstones[0].HostID != host.ID {
+ t.Fatalf("removal tombstones = %+v, want host %q", tombstones, host.ID)
+ }
+}
+
func TestHostAgentRemovalLifecycleDoesNotPoisonDuplicateActiveIdentity(t *testing.T) {
monitor := newHostRemovalLifecycleMonitor(t, t.TempDir())
now := time.Now().UTC()
diff --git a/internal/monitoring/monitored_system_usage.go b/internal/monitoring/monitored_system_usage.go
index 3a099aa0df..6d1545494e 100644
--- a/internal/monitoring/monitored_system_usage.go
+++ b/internal/monitoring/monitored_system_usage.go
@@ -108,7 +108,12 @@ func (m *Monitor) readStateWithStandaloneHostContinuity(
if _, ok := existingAgentIDs[hostID]; ok {
continue
}
- records = append(records, unifiedresources.HostIngestRecord(hostFromContinuityEntry(entry)))
+ // A continuity-only row has no live report in this monitor generation.
+ // Preserve its last-known identity so the operator can inspect or remove
+ // it, but never present persisted telemetry as a current online sighting.
+ host := hostFromContinuityEntry(entry)
+ host.Status = "offline"
+ records = append(records, unifiedresources.HostIngestRecord(host))
}
if len(records) == 0 {
return readState