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.

Preserve reviewed monitoring repairs with current upstream overviews

pulse-triage[bot]e02f949b09ac
diff --cc internal/unifiedresources/registry_test.go
index 608e291880,6a721e846a..e7490bef07
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@@ -6908,23 -6908,42 +6908,63 @@@ func TestAgentNodeScanIndexTracksAgents
}
}
+func TestRegistryBulkMetadataInvalidatesAtRecordBoundary(t *testing.T) {
+ rr := NewRegistry(nil)
+ rr.IngestRecords(SourceAgent, []IngestRecord{{SourceID: "host", Resource: Resource{Type: ResourceTypeAgent, Name: "before", Status: StatusOnline, LastSeen: time.Now().UTC(), Agent: &AgentData{AgentID: "host", Hostname: "before.example.test"}}}})
+ rr.List()
+ previous := rr.Hosts()[0]
+ id := rr.ingestRecord(SourceAgent, "host", Resource{Type: ResourceTypeAgent, Name: "after", Status: StatusOnline, LastSeen: time.Now().UTC(), Agent: &AgentData{AgentID: "host", Hostname: "after.example.test"}}, ResourceIdentity{}, false)
+ // This is the real record boundary, before parent/rollup batch finalization.
+ actual := assertRegistryMetadataOracle(t, rr)
+ if actual[0].Canonical.Hostname != "after.example.test" || rr.Hosts()[0].Name() != "after" {
+ t.Fatal("record mutation reused pre-batch metadata or views")
+ }
+ if previous.Name() != "before" {
+ t.Fatal("record mutation rewrote an already returned view")
+ }
+ rr.retainSupersededCanonicalIDs(id, []string{"agent:prior-era"})
+ actual = assertRegistryMetadataOracle(t, rr)
+ if len(actual[0].Canonical.SupersededIDs) != 1 || actual[0].Canonical.SupersededIDs[0] != "agent:prior-era" {
+ t.Fatal("superseded identity retention failed to invalidate bulk metadata")
+ }
+}
++
+ func TestEvaluateResourceHealthKeepsStaleTelemetryBehindAWinningAlert(t *testing.T) {
+ now := time.Date(2026, 10, 5, 1, 0, 0, 0, time.UTC)
+ silent := Resource{
+ ID: "docker-host-1",
+ Type: ResourceTypeAgent,
+ Status: StatusOnline,
+ LastSeen: now.Add(-70 * time.Minute),
+ SourceStatus: map[DataSource]SourceStatus{
+ SourceDocker: {Status: "stale", LastSeen: now.Add(-70 * time.Minute)},
+ },
+ }
+
+ // The alert still explains the verdict first, and the silence follows it
+ // so tables can stop presenting the host's last readings as live.
+ health := EvaluateResourceHealth(silent, []ResourceHealthAlert{{ResourceID: "docker-host-1", Level: "critical", Type: "docker-host-offline"}}, now)
+ if health.Verdict != HealthCritical || len(health.Reasons) != 2 {
+ t.Fatalf("expected critical with two reasons, got %+v", health)
+ }
+ if health.Reasons[0].Code != "critical_alert" {
+ t.Fatalf("expected the alert to stay the first reason, got %+v", health.Reasons)
+ }
+ if health.Reasons[1] != (ResourceHealthReason{Code: "telemetry_stale", Detail: "1h"}) {
+ t.Fatalf("expected a trailing telemetry_stale reason with the age, got %+v", health.Reasons[1])
+ }
+
+ // Without an alert the stale verdict carries the single reason as before.
+ health = EvaluateResourceHealth(silent, nil, now)
+ if health.Verdict != HealthStale || len(health.Reasons) != 1 || health.Reasons[0].Code != "telemetry_stale" {
+ t.Fatalf("expected a lone stale reason, got %+v", health)
+ }
+
+ // A fresh source adds nothing behind an alert.
+ fresh := silent
+ fresh.SourceStatus = map[DataSource]SourceStatus{SourceDocker: {Status: "online", LastSeen: now}}
+ health = EvaluateResourceHealth(fresh, []ResourceHealthAlert{{ResourceID: "docker-host-1", Level: "warning", Type: "cpu"}}, now)
+ if len(health.Reasons) != 1 {
+ t.Fatalf("expected only the alert reason for a fresh source, got %+v", health.Reasons)
+ }
+ }