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
test(monitoring): protect manual links against stale association cleanup
pulse-triage[bot]c268d25e54ed
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 2ddfb9dcf0..d3a52b6029 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -7860,3 +7860,30 @@ bridge on either side alone must not supply inferred identity: testing onlysymmetric bridges would miss removal of filtering from one inventory.This proof does not establish safety for arbitrarily renamed Docker bridgesor repair persisted links, and is not reporter or installed-release validation.++### Manual host/node association safety boundary (6 September 2026)++`TestManualHostLinkSurvivesUnmatchedReportsAndProviderRefresh` protects an+operator-created association between `nas.example` and an otherwise unmatched+`pve` node through repeated reports, `UpdateNodesForInstance`, and explicit+unlink. Reapplying the rejected stale-link cleanup plus provider-name matcher+change makes the first report fail this regression. Neither change is included+with this test.++Restart remains an independently reproduced gap, not a supported invariant:+using `newHostRemovalLifecycleMonitor` with a temporary data directory, submit+`hostRemovalLifecycleReport("machine", "machine", "agent", "nas.example",+"linux", now)`, populate the unmatched `pve-node`, and call `LinkHostAgent`.+Reconstructing the monitor from the same directory immediately yields a host+without the link. Sending another report before reconstruction persists the+link, but refreshing the provider on the reconstructed monitor and submitting+the next report still returns an empty `LinkedNodeID`.++`LinkHostAgent` currently changes state only. `HostContinuityEntry` stores the+target ID but no manual/automatic provenance. Legacy manual and automatic links+can therefore have identical persisted representations. A repair must not+classify every unmarked legacy link as automatic. Durable operator intent,+failed-write handling, provider identity changes, and explicit unlink across+restart need coverage before enabling destructive stale-link cleanup. This is+maintenance evidence, not demand for a new user-visible linking surface or a+claim of resolution of issue #1930.diff --git a/internal/monitoring/host_manual_link_regression_test.go b/internal/monitoring/host_manual_link_regression_test.gonew file mode 100644index 0000000000..0daf6a0b3d--- /dev/null+++ b/internal/monitoring/host_manual_link_regression_test.go@@ -0,0 +1,54 @@+package monitoring++import (+ "testing"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/models"+)++// An unmatched report is not an operator request to unlink. In particular,+// repairing old automatic associations must not erase a manual association.+func TestManualHostLinkSurvivesUnmatchedReportsAndProviderRefresh(t *testing.T) {+ monitor := issue1654Monitor()+ report := issue1654Report(time.Now().UTC())+ report.Host.Hostname = "nas.example"+ report.Host.ReportIP = ""+ report.Network = nil+ host, err := monitor.ApplyHostReport(report, nil)+ if err != nil {+ t.Fatal(err)+ }+ node := models.Node{ID: "pve-node", Name: "pve", Instance: "cluster", Host: "https://pve.example:8006"}+ monitor.state.UpdateNodesForInstance("cluster", []models.Node{node})+ if err := monitor.LinkHostAgent(host.ID, node.ID); err != nil {+ t.Fatal(err)+ }+ for i := 0; i < 2; i++ {+ report.Timestamp = report.Timestamp.Add(time.Second)+ host, err = monitor.ApplyHostReport(report, nil)+ if err != nil {+ t.Fatal(err)+ }+ if host.LinkedNodeID != node.ID {+ t.Fatalf("manual host link after report %d = %q, want %q", i, host.LinkedNodeID, node.ID)+ }+ monitor.state.UpdateNodesForInstance("cluster", []models.Node{node})+ snapshot := monitor.state.GetSnapshot()+ if len(snapshot.Nodes) != 1 || snapshot.Nodes[0].LinkedAgentID != host.ID {+ t.Fatalf("provider refresh lost manual reverse link: %+v", snapshot.Nodes)+ }+ if got := monitor.state.GetHosts()[0].LinkedNodeID; got != node.ID {+ t.Fatalf("provider refresh host link = %q", got)+ }+ }+ if err := monitor.UnlinkHostAgent(host.ID); err != nil {+ t.Fatal(err)+ }+ if got := monitor.state.GetHosts()[0].LinkedNodeID; got != "" {+ t.Fatalf("explicit unlink retained host link %q", got)+ }+ if got := monitor.state.GetSnapshot().Nodes[0].LinkedAgentID; got != "" {+ t.Fatalf("explicit unlink retained node link %q", got)+ }+}