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
fix(monitoring): clear host removal blocks from every store on re-enroll
rcourtmanb67ac28f2543
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 06947835ec..3d5114c994 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -6562,3 +6562,13 @@ retains the last successful aggregate after failure, so a slow appliancedaemon cannot be held busy by an immediate retry followed by another scan onthe next report tick. This changes neither agent enrollment nor reportauthority; it bounds the collection work attached to that lifecycle (#1729).++### Host removal blocks clear from every store on re-enroll++A host-agent removal block may live in the durable continuity store, the+legacy in-memory map, or persisted monitor state written by releases that+predate the durable store. The re-enroll transition honors whichever store+still holds the block. A state-only block with a durable store attached is+cleared rather than read as already-consumed, so a fresh token minted after+removal always re-enrolls the host instead of rejecting its reports+indefinitely with 400s that no reinstall can escape (#1772).diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 34249804c5..75b30d2da0 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -1116,6 +1116,15 @@ tighten it only when a freshly shortened interval justifies an earlier run.Without this, a sixty-second availability target polls at the ten-secondtick cadence whenever adaptive polling is off, which is the default.+### Host report admission does not wedge on stale removal blocks++Host-agent report admission consults removal blocks across the durable+continuity store, the legacy in-memory map, and persisted monitor state.+Clearing a block on re-enroll honors whichever store still holds it (the+agent-lifecycle contract carries the matching clause), so admission cannot+wedge into permanent 400s for a host whose block predates the durable+store.+### Large Proxmox generations preserve reachability under bounded enrichmentThe efficient PVE poll reserves a fixed tail of the scheduler deadline anddiff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.goindex 8ff910f895..ceb24db22e 100644--- a/internal/monitoring/monitor_agents.go+++ b/internal/monitoring/monitor_agents.go@@ -646,10 +646,13 @@ func (m *Monitor) allowHostAgentReenrollLocked(}}- transitioned := existsOnDisk- if !hasDurableStore {- transitioned = existsInMemory || existsInState- }+ // A removal block can live in the durable store, the legacy in-memory+ // map, or persisted monitor state written by releases that predate the+ // durable store. Clearing must honor whichever still holds the block:+ // trusting only the durable store leaves a state-only block permanently+ // un-clearable after an upgrade, so every fresh re-enroll reads as+ // "already consumed" and the host can never report again (#1772).+ transitioned := existsOnDisk || existsInMemory || existsInStateif !transitioned {log.Info().Str("hostID", hostID).diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.goindex a643c3af48..e247409592 100644--- a/internal/monitoring/monitor_host_agents_test.go+++ b/internal/monitoring/monitor_host_agents_test.go@@ -3890,6 +3890,41 @@ func TestAllowHostAgentReenroll_ClearsStateMirrorWithoutMemoryEntry(t *testing.T}}+// Regression for #1772: a removal block that lives only in persisted monitor+// state (written before the durable continuity store existed) must still be+// clearable when a durable store is attached, or every fresh re-enroll reads+// as already-consumed and the host can never report again.+func TestAllowHostAgentReenroll_ClearsStateMirrorWhenDurableStoreLacksEntry(t *testing.T) {+ monitor := &Monitor{+ state: models.NewState(),+ alertManager: alerts.NewManager(),+ hostTokenBindings: make(map[string]string),+ removedHostAgents: make(map[string]time.Time),+ rateTracker: NewRateTracker(),+ config: &config.Config{},+ hostContinuityStore: config.NewHostContinuityStore(t.TempDir(), nil),+ }+ t.Cleanup(func() { monitor.alertManager.Stop() })++ hostID := "host-upgrade-block"+ monitor.state.AddRemovedHostAgent(models.RemovedHostAgent{+ ID: hostID,+ Hostname: "npm.local",+ RemovedAt: time.Now().Add(-time.Hour),+ })++ cleared, err := monitor.allowHostAgentReenrollLocked(hostID, "token-fresh", false)+ if err != nil {+ t.Fatalf("allowHostAgentReenrollLocked: %v", err)+ }+ if !cleared {+ t.Fatal("expected state-only removal block to report cleared with a durable store attached")+ }+ if len(monitor.state.GetRemovedHostAgents()) != 0 {+ t.Fatal("expected state removal block to be cleared")+ }+}+// TestCleanupRemovedHostAgents_ExpiresStateMirrorEntries pins expiry for// models.State-only compatibility entries when the in-memory map lacks them.func TestCleanupRemovedHostAgents_ExpiresStateMirrorEntries(t *testing.T) {