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 completed guest inventory after a caller deadline

pulse-triage[bot]942350d42a8c
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 68618092f9..4bbc080672 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -7296,8 +7296,10 @@ replacement's guest readings. An interrupted inventory does not grant fallback.
One cycle per live binding owns collection until it completes, including when
its caller is cancelled. Another connection can still advance independently.
-Deep-enrichment expiry is distinct from parent-cycle cancellation: a complete
-authoritative inventory still publishes within the reserved parent tail. An
+Deep-enrichment/caller-deadline expiry is distinct from explicit parent-cycle
+cancellation: already collected authoritative inventory still publishes even
+when local assembly outlasts the caller budget. No new read or fallback is
+admitted after deadline expiry. An
accepted collection retains existing failed-node/grace rules, empty-inventory
handling and metric/source/age policy. Focused builder and collector entry points
retain their existing immediate effects. No guest operation lock, consumed-read
diff --git a/internal/monitoring/guest_poll_publication.go b/internal/monitoring/guest_poll_publication.go
index 2d152453e4..7bb6713ec4 100644
--- a/internal/monitoring/guest_poll_publication.go
+++ b/internal/monitoring/guest_poll_publication.go
@@ -2,6 +2,7 @@ package monitoring
import (
"context"
+ "errors"
"sync"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
@@ -10,7 +11,8 @@ import (
// A guest cycle collects outside publication locks. Its effects are staged
// until both guest kinds are ready and the registered connection still owns
// this cycle. Child enrichment deadlines do not invalidate an authoritative
-// inventory; cancellation of the parent cycle does.
+// inventory. An expired caller budget also keeps completed inventory usable;
+// explicit cancellation of the parent cycle does not.
type pveGuestPoll struct {
ctx context.Context
cancel context.CancelFunc
@@ -87,7 +89,12 @@ func (m *Monitor) publishPVEGuests(ctx context.Context, instance string, vms []m
m.pveGuestPublicationMu.RLock()
defer m.pveGuestPublicationMu.RUnlock()
m.mu.RLock()
- current := owner.ctx.Err() == nil && m.pveGuestPolls[instance] == owner && m.pveClients[instance] == owner.client && (m.runtimeCtx == nil || m.runtimeCtx.Err() == nil)
+ cycleErr := owner.ctx.Err()
+ // A caller deadline bounds remote enrichment, not the lifetime of the
+ // configured connection. Keep the existing authoritative-inventory tail
+ // even if local assembly outlasts that budget. Explicit cancellation, an
+ // ended runtime or a changed binding still withdraws the entire cycle.
+ current := (cycleErr == nil || errors.Is(cycleErr, context.DeadlineExceeded)) && m.pveGuestPolls[instance] == owner && m.pveClients[instance] == owner.client && (m.runtimeCtx == nil || m.runtimeCtx.Err() == nil)
m.mu.RUnlock()
if !current {
return
diff --git a/internal/monitoring/proxmox_large_cluster_poll_budget_test.go b/internal/monitoring/proxmox_large_cluster_poll_budget_test.go
index 93f5668ef9..018646b8e1 100644
--- a/internal/monitoring/proxmox_large_cluster_poll_budget_test.go
+++ b/internal/monitoring/proxmox_large_cluster_poll_budget_test.go
@@ -105,9 +105,9 @@ func TestLargePVEClusterPublishesCompleteGenerationWhenEnrichmentBudgetExpires(t
resources: largeClusterResources(),
}
monitor.replacePVEClient("large-cluster", client)
- // Expire only deep enrichment. The parent still owns the authoritative
- // inventory and its reserved publication tail, unlike explicit cancellation.
- ctx, cancel := context.WithTimeout(context.Background(), pvePollTailReserve-time.Second)
+ // Deadline exhaustion must not lose completed authoritative inventory.
+ // It is distinct from explicit cancellation or a retired connection.
+ ctx, cancel := context.WithTimeout(context.Background(), 40*time.Millisecond)
defer cancel()
started := time.Now()
@@ -187,9 +187,7 @@ func TestLargePVEClusterCoreSuccessKeepsConnectionHealthy(t *testing.T) {
monitor.config.PVEInstances[0].MonitorContainers = true
monitor.replacePVEClient("large-cluster", client)
- // This models an already exhausted detail budget, not cancellation of the
- // entire connection cycle. Leave its authoritative publication tail alive.
- ctx, cancel := context.WithTimeout(context.Background(), pvePollTailReserve-time.Second)
+ ctx, cancel := context.WithTimeout(context.Background(), 250*time.Millisecond)
defer cancel()
monitor.pollPVEInstance(ctx, "large-cluster", client)