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 current guest admission through repeated canonical reads

pulse-triage[bot]bfdb1f1a47e7
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 0db618b95a..707390d6cc 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,22 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### Native guest admission replaces the previous canonical facet
+
+A complete native Proxmox guest observation (non-zero VMID) owns its filesystem
+read reason, guest-agent state and expectation in both directions. Repeated
+ingestion must publish a new cooldown even when the retained disk number is
+unchanged, and clear the reason/expectation when the native guest recovers or is
+disabled. Non-guest partial Proxmox facets do not own these fields. Numeric
+source selection, original memory observation times and identity stay unchanged.
+
+`TestProxmoxGuestReadAdmissionReplacesPreviousFacet` covers available, paused,
+recovered, offline and disabled transitions through repeated registry ingestion,
+typed/detached reads and JSON. Monitoring's connected optional-command proof
+also consumes that same live registry and production broadcast JSON while
+checking History withholding. Source clearance is not independent guest thaw,
+covered-filesystem writes or native monitoring recovery.
+
### Canonical Discovery honours VM guest-read deferrals
The canonical resource drawer uses the same fixed PVE VM lock, backup and
diff --git a/internal/monitoring/guest_agent_optional_read_integration_test.go b/internal/monitoring/guest_agent_optional_read_integration_test.go
index 78a38df949..78b482fced 100644
--- a/internal/monitoring/guest_agent_optional_read_integration_test.go
+++ b/internal/monitoring/guest_agent_optional_read_integration_test.go
@@ -122,7 +122,13 @@ func testGuestAgentOptionalReadOrdering(t *testing.T, withoutStatus bool) {
id := makeGuestID("optional", "node", 105)
var previous *models.VM
if withoutStatus {
- previous = &models.VM{ID: id, GuestAgentStatus: "available", Status: "running", LastSeen: time.Now()}
+ previous = &models.VM{ID: id, Type: "qemu", GuestAgentStatus: "available", Status: "running", LastSeen: time.Now()}
+ // Prior useful identity admits the bounded no-status path.
+ // Expired metadata is retained on uncertainty, not renewed by
+ // the new request. It must not suppress the optional control.
+ m.guestMetadataCache = map[string]guestMetadataCacheEntry{
+ guestMetadataCacheKey("optional", "node", 105): {agentVersion: "prior", fetchedAt: time.Now().Add(-2 * guestMetadataCacheTTL)},
+ }
}
build := func() models.VM {
vm, raw, source, notes, at, ok := m.buildVMFromClusterResource(context.Background(), "optional", res, client, id, nil, previous)
@@ -141,6 +147,14 @@ func testGuestAgentOptionalReadOrdering(t *testing.T, withoutStatus bool) {
if err != nil || !strings.Contains(string(encoded), canonicalID) {
t.Fatal("guest identity missing from JSON read projection")
}
+ var served []models.ResourceFrontend
+ if err := json.Unmarshal(encoded, &served); err != nil || len(served) != 1 {
+ t.Fatal("guest missing from production JSON")
+ }
+ var facet unifiedresources.ProxmoxData
+ if err := json.Unmarshal(served[0].Proxmox, &facet); err != nil || facet.DiskStatusReason != vm.DiskStatusReason || facet.GuestAgentStatus != vm.GuestAgentStatus || facet.GuestAgentExpected != vm.GuestAgentExpected {
+ t.Fatal("guest admission state changed in production JSON")
+ }
next := previousVMFromView(view)
previous = &next
return vm
@@ -164,6 +178,7 @@ func testGuestAgentOptionalReadOrdering(t *testing.T, withoutStatus bool) {
}
memoryKey := guestMemoryCacheKey("optional", "node", 105)
originalMemory := m.vmAgentMemCache[memoryKey]
+ originalMetadata := m.guestMetadataCache[guestMetadataCacheKey("optional", "node", 105)]
originalDisk := guestHistoryStoredPoints(t, m, "vm", id, "disk")
if len(originalDisk) != 1 || originalDisk[0].Value != 30 {
t.Fatal("initial filesystem did not reach persistent History")
@@ -186,6 +201,9 @@ func testGuestAgentOptionalReadOrdering(t *testing.T, withoutStatus bool) {
if !reflect.DeepEqual(m.vmAgentMemCache[memoryKey], originalMemory) || (originalMemory.info.Source != "" && !vm.Memory.Observation.ObservedAt.Equal(initial.Memory.Observation.ObservedAt)) {
t.Fatal("cooldown renewed original memory evidence")
}
+ if !reflect.DeepEqual(m.guestMetadataCache[guestMetadataCacheKey("optional", "node", 105)], originalMetadata) {
+ t.Fatal("cooldown renewed original metadata evidence")
+ }
}
}
if !tc.terminal {
diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.go
index 34992538c1..da148d3ef5 100644
--- a/internal/unifiedresources/registry.go
+++ b/internal/unifiedresources/registry.go
@@ -3870,6 +3870,13 @@ func mergeProxmoxData(existing *ProxmoxData, incoming *ProxmoxData) *ProxmoxData
}
if incoming.VMID != 0 {
merged.VMID = incoming.VMID
+ // A native guest facet is a complete observation of admission state.
+ // Retaining the previous reason/status can hide a newly paused read or
+ // leave a recovered guest paused forever. Non-guest partial facets do
+ // not own these fields.
+ merged.DiskStatusReason = incoming.DiskStatusReason
+ merged.GuestAgentStatus = incoming.GuestAgentStatus
+ merged.GuestAgentExpected = incoming.GuestAgentExpected
}
if incoming.CPUs != 0 {
merged.CPUs = incoming.CPUs
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 8eacc8f37b..b9e2ae854c 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -12,6 +12,43 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"
)
+func TestProxmoxGuestReadAdmissionReplacesPreviousFacet(t *testing.T) {
+ rr := NewRegistry(nil)
+ vm := models.VM{ID: "pve:node:105", Instance: "pve", Node: "node", VMID: 105, Type: "qemu", Status: "running", Name: "guest", LastSeen: time.Now(), Disk: models.Disk{Total: 100, Used: 30, Usage: 30}}
+ for _, tc := range []struct {
+ status, reason string
+ expected bool
+ }{
+ {"available", "", true},
+ {"deferred", "prev-agent-cooldown", true},
+ {"available", "", true},
+ {"not-running", "agent-not-running", false},
+ {"disabled", "agent-disabled", false},
+ } {
+ vm.GuestAgentStatus, vm.DiskStatusReason, vm.GuestAgentExpected = tc.status, tc.reason, tc.expected
+ rr.IngestSnapshot(models.StateSnapshot{VMs: []models.VM{vm}})
+ views := rr.VMs()
+ if len(views) != 1 || views[0].DiskStatusReason() != tc.reason {
+ t.Fatalf("current disk admission missing from typed view: %q", tc.reason)
+ }
+ resource, ok := rr.Get(views[0].ID())
+ if !ok || resource.Proxmox == nil || resource.Proxmox.GuestAgentStatus != tc.status || resource.Proxmox.GuestAgentExpected != tc.expected {
+ t.Fatalf("current guest admission missing from resource: %+v", resource)
+ }
+ // A detached read and JSON retain the current state, including a cleared
+ // reason/false expectation. Non-guest partial facets cannot erase it.
+ encoded, err := json.Marshal(resource)
+ var served Resource
+ if err != nil || json.Unmarshal(encoded, &served) != nil || served.Proxmox.DiskStatusReason != tc.reason || served.Proxmox.GuestAgentStatus != tc.status || served.Proxmox.GuestAgentExpected != tc.expected {
+ t.Fatal("read JSON changed guest admission")
+ }
+ partial := mergeProxmoxData(resource.Proxmox, &ProxmoxData{NodeName: "node"})
+ if partial.DiskStatusReason != tc.reason || partial.GuestAgentStatus != tc.status || partial.GuestAgentExpected != tc.expected {
+ t.Fatal("partial non-guest facet erased guest-owned admission")
+ }
+ }
+}
+
func TestRegistry_CachedReadsUseSharedLock(t *testing.T) {
rr := NewRegistry(nil)
// A clean, empty registry already has a valid empty cache. Holding another