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
Remove dead cache-aware RRD fields from the guest RRD path
[email protected]1dc19bfec02b
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex a756eca96e..cc3e2655b3 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -2201,6 +2201,19 @@ Agent` secondary handoff against the live setup wizard instead of relying## Current State+### Monitor housekeeping prunes only live memory-evidence caches++The shared monitor housekeeping pass in `internal/monitoring/monitor_agents.go`+(`cleanupRRDCache`) prunes exactly two short-lived memory-evidence caches: the+node RRD cache and the guest-agent meminfo cache keyed by+`(instance, node, vmid)`. The former per-VM guest RRD memory cache was removed+along with `GuestRRDPoint`'s fictional `memused`/`memavailable` columns —+recorded PVE 8/9 guest `rrddata` responses never carry them (#1634) — so+monitor construction in `internal/monitoring/monitor.go` no longer initializes+a guest RRD cache and housekeeping must not regrow one. Stale guest-agent+entries age out under `vmAgentMemCleanupMaxAge` so removed or re-enrolled+guests cannot replay old agent memory evidence.+### Command-channel token binding is one decision consumed by every surfaceAgent exec token binding is evaluated by a single decision functiondiff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex adb023c2e4..f60cd3507d 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -1853,39 +1853,42 @@ against the effective balloon total and prefer that fallback over `status-mem`when Proxmox reports a saturated or materially inconsistent used figure, soWindows and ballooned guests do not get pinned to false 100% usage samples.That same guest-memory boundary also owns fallback order and cache scoping for-Proxmox VMs when `MemInfo` is absent. Monitoring must try instance-scoped RRD-`memavailable`, RRD `memused`, guest-agent `/proc/meminfo` via the shared-Proxmox client, and only then linked host-agent memory. Saturated Linux VM-status is the narrow exception: a queryable guest agent's cache-aware-`/proc/meminfo` evidence is tried before RRD because the saturated status is-the known Proxmox failure mode. Both RRD and guest-agent fallback caches must-key on `(instance, node, vmid)` instead of raw `node/vmid`, so separate-Proxmox instances cannot leak stale or foreign memory evidence into each other-just because they reuse the same node name and VMID.+Proxmox VMs when `MemInfo` is absent. Guest RRD is not a memory evidence+source: recorded PVE 8 and PVE 9 guest `rrddata` responses (fixtures under+`pkg/proxmox/testdata/rrd/`) prove the cache-aware `memavailable`/`memused`+columns exist only in node RRD, so `GuestRRDPoint` parses only the recorded+guest columns (`time`, `maxmem`), `PVEClientInterface` exposes no guest RRD+lookups, and the VM memory resolver must not consult the guest RRD endpoint+(#1634). Monitoring must try guest-agent `/proc/meminfo` via the shared+Proxmox client, and only then linked host-agent memory. Guest-agent fallback+caches must key on `(instance, node, vmid)` instead of raw `node/vmid`, so+separate Proxmox instances cannot leak stale or foreign memory evidence into+each other just because they reuse the same node name and VMID.Linux memory availability must never be inferred from `MemTotal-MemFree`.Nodes and guests prefer a valid explicit `MemAvailable`/`available` field,-then a complete reclaimable-component estimate, then valid RRD availability or-used evidence. The conservative old-kernel guest-agent estimate is+then a complete reclaimable-component estimate, then — for nodes, where the+columns actually exist — valid node RRD availability or used evidence. The+conservative old-kernel guest-agent estimate is`MemFree + Buffers + Cached + SReclaimable - Shmem`; it is valid without swapbut not from truncated or total/free-only meminfo. A material `total-used`gap may remain a lower-trust estimate only when it supplies independentevidence that the reported used value already excludes cache. Invalid,overflowed, non-finite, over-total, or conflicting candidates must be rejected-before the next source is considered; an explicitly present zero RRD used or-zero available value remains a valid idle or full-pressure sample rather than-being mistaken for an absent field.-Node RRD fallback caches must key on `(instance, node)`, just as guest RRD and-guest-agent caches key on `(instance, node, vmid)`, so identically named nodes-in different Proxmox instances cannot exchange memory evidence.-Running LXC memory acknowledges a Proxmox API reality: guest RRD responses-carry only cache-inclusive `mem`/`maxmem` columns — the cache-aware-`memavailable`/`memused` columns exist only in node RRD — so cache-aware LXC-evidence is structurally absent from the guest RRD endpoint. When the-cache-aware RRD branches do not match, a running container with a non-zero-cluster-resource listing value must fall back to that cache-inclusive value-under the low-trust `cluster-resources` source rather than reporting the-guest unavailable; `unavailable` is reserved for running containers with no-listing evidence at all (#1634).+before the next source is considered; an explicitly present zero node RRD used+or zero available value remains a valid idle or full-pressure sample rather+than being mistaken for an absent field.+Node RRD fallback caches must key on `(instance, node)`, just as guest-agent+caches key on `(instance, node, vmid)`, so identically named nodes in+different Proxmox instances cannot exchange memory evidence.+Running LXC memory acknowledges the same Proxmox API reality: guest RRD+responses carry only cache-inclusive `mem`/`maxmem` columns, so the LXC+memory path performs no guest RRD lookup at all. A running container with a+non-zero cluster-resource listing value must report that cache-inclusive+value under the low-trust `cluster-resources` source rather than reporting+the guest unavailable; `unavailable` is reserved for running containers with+no listing evidence at all (#1634). The guest sources `rrd-memavailable` and+`rrd-memused` are node-only labels now; guest reliability scoring must not+treat them as trusted guest evidence.Unified Linux and Docker agent ingest likewise must not repair a missing usedvalue from total minus free alone; it may use an explicit used/percentage orcomplete free-plus-cache evidence. In every collector, known capacity with nodiff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.goindex 4e6911e7a2..fd1f035e1d 100644--- a/internal/monitoring/canonical_guardrails_test.go+++ b/internal/monitoring/canonical_guardrails_test.go@@ -891,17 +891,16 @@ func TestProxmoxGuestMemoryFallbackUsesInstanceScopedCachesAndAgentMeminfo(t *te"func shouldPreferGuestAgentMemAvailable(status *proxmox.VMStatus, memTotal uint64) bool {","func (m *Monitor) tryGuestAgentMemAvailable(","if !hasMemAvailable && shouldPreferGuestAgentMemAvailable(status, memTotal) {",- "if rrdMemory, rrdErr := m.getVMRRDMemory(ctx, client, instanceName, node, vmid); rrdErr == nil {",- "case rrdMemory.hasUsed && rrdMemory.used <= memTotal:",+ // Guest rrddata carries no cache-aware memory columns (#1634):+ // the resolver must not consult guest RRD between the preferred+ // guest-agent pass and the retry pass.+ "// No RRD fallback here: PVE guest rrddata carries only cache-inclusive","if agentAvailable, agentSource, ok := m.tryGuestAgentMemAvailable(ctx, client, instanceName, guestName, node, vmid, memTotal, guestRaw); ok {","memorySource = agentSource","guestRaw.GuestAgentMemAvailable = agentAvailable",`memorySource = "unavailable"`,},"monitor.go": {- "func (m *Monitor) getVMRRDMetrics(ctx context.Context, client PVEClientInterface, instanceName, node string, vmid int) (uint64, error) {",- "func (m *Monitor) getVMRRDMemory(ctx context.Context, client PVEClientInterface, instanceName, node string, vmid int) (rrdMemCacheEntry, error) {",- "cacheKey := guestMemoryCacheKey(instanceName, node, vmid)","vmAgentMemCache map[string]agentMemCacheEntry",},"monitor_agents.go": {diff --git a/internal/monitoring/diagnostic_snapshots.go b/internal/monitoring/diagnostic_snapshots.goindex 0edc2588c9..ee9ba5b520 100644--- a/internal/monitoring/diagnostic_snapshots.go+++ b/internal/monitoring/diagnostic_snapshots.go@@ -70,9 +70,6 @@ type VMMemoryRaw struct {GuestAgentSReclaimable uint64 `json:"guestAgentSReclaimable,omitempty"`GuestAgentShmem uint64 `json:"guestAgentShmem,omitempty"`GuestAgentDerived bool `json:"guestAgentDerived,omitempty"`- RRDMemAvailable uint64 `json:"rrdMemAvailable,omitempty"`- RRDMemUsed uint64 `json:"rrdMemUsed,omitempty"`- RRDMaxMem uint64 `json:"rrdMaxMem,omitempty"`HostAgentTotal uint64 `json:"hostAgentTotal,omitempty"`HostAgentUsed uint64 `json:"hostAgentUsed,omitempty"`Agent int `json:"agent,omitempty"`@@ -268,12 +265,6 @@ func (m *Monitor) logGuestMemorySource(instance, guestType, node string, vmid inif snapshot.Raw.GuestAgentDerived {evt = evt.Bool("guestAgentDerived", true)}- if snapshot.Raw.RRDMemAvailable > 0 {- evt = evt.Uint64("rrdMemAvailable", snapshot.Raw.RRDMemAvailable)- }- if snapshot.Raw.RRDMemUsed > 0 {- evt = evt.Uint64("rrdMemUsed", snapshot.Raw.RRDMemUsed)- }if snapshot.Raw.MemInfoBuffers > 0 {evt = evt.Uint64("memInfoBuffers", snapshot.Raw.MemInfoBuffers)}diff --git a/internal/monitoring/guest_memory_agent_test.go b/internal/monitoring/guest_memory_agent_test.goindex 53c3f22365..786691e3e0 100644--- a/internal/monitoring/guest_memory_agent_test.go+++ b/internal/monitoring/guest_memory_agent_test.go@@ -11,7 +11,6 @@ import (type guestMemoryAgentTestClient struct {*stubPVEClient- vmRRDPoints []proxmox.GuestRRDPointmemAvailable uint64memInfo *proxmox.LinuxMemoryAvailabilitymemErr error@@ -19,9 +18,12 @@ type guestMemoryAgentTestClient struct {memCalls int}+// GetVMRRDData tracks lookups of the guest RRD endpoint. It is intentionally+// not part of PVEClientInterface anymore: guest rrddata carries no cache-aware+// memory columns (#1634), so the memory resolvers must never consult it.func (c *guestMemoryAgentTestClient) GetVMRRDData(ctx context.Context, node string, vmid int, timeframe, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {c.rrdCalls++- return c.vmRRDPoints, nil+ return nil, nil}func (c *guestMemoryAgentTestClient) GetVMMemAvailableFromAgent(ctx context.Context, node string, vmid int) (uint64, error) {@@ -50,69 +52,39 @@ func (c *guestMemoryAgentTestClient) GetVMMemoryAvailabilityFromAgent(ctx contex}, nil}-func TestGetVMRRDMetricsCacheKeyIncludesInstance(t *testing.T) {- t.Parallel()-- giB := float64(1024 * 1024 * 1024)- mon := &Monitor{vmRRDMemCache: make(map[string]rrdMemCacheEntry)}- clientA := &guestMemoryAgentTestClient{- stubPVEClient: &stubPVEClient{},- vmRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(3 * giB)}},- }- clientB := &guestMemoryAgentTestClient{- stubPVEClient: &stubPVEClient{},- vmRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(5 * giB)}},- }-- gotA, err := mon.getVMRRDMetrics(context.Background(), clientA, "pve-a", "node1", 100)- if err != nil {- t.Fatalf("getVMRRDMetrics(pve-a) error = %v", err)- }- gotB, err := mon.getVMRRDMetrics(context.Background(), clientB, "pve-b", "node1", 100)- if err != nil {- t.Fatalf("getVMRRDMetrics(pve-b) error = %v", err)- }-- if gotA != 3*1024*1024*1024 {- t.Fatalf("getVMRRDMetrics(pve-a) = %d, want %d", gotA, uint64(3*1024*1024*1024))- }- if gotB != 5*1024*1024*1024 {- t.Fatalf("getVMRRDMetrics(pve-b) = %d, want %d", gotB, uint64(5*1024*1024*1024))- }- if clientA.rrdCalls != 1 || clientB.rrdCalls != 1 {- t.Fatalf("expected isolated cache fetches, got clientA=%d clientB=%d", clientA.rrdCalls, clientB.rrdCalls)- }-}--func TestResolveGuestStatusMemoryAcceptsExplicitZeroRRDUsed(t *testing.T) {+func TestResolveGuestStatusMemoryNeverConsultsGuestRRD(t *testing.T) {t.Parallel()+ // Guest rrddata carries only cache-inclusive mem/maxmem columns; the+ // cache-aware memused/memavailable columns exist only in node RRD, so+ // an agentless VM without meminfo must land on the low-trust status+ // value instead of issuing a guest RRD lookup that cannot succeed+ // (#1634).const gib = uint64(1024 * 1024 * 1024)- mon := &Monitor{vmRRDMemCache: make(map[string]rrdMemCacheEntry)}+ mon := &Monitor{}client := &guestMemoryAgentTestClient{stubPVEClient: &stubPVEClient{},- vmRRDPoints: []proxmox.GuestRRDPoint{{- MaxMem: floatPtr(float64(8 * gib)),- MemUsed: floatPtr(0),- }},}total, used, source := mon.resolveGuestStatusMemory(context.Background(),client,"pve-a",- "idle-vm",+ "agentless-vm","node1",100,"pve-a:node1:100",- &proxmox.VMStatus{MaxMem: 8 * gib, Mem: 8 * gib},+ &proxmox.VMStatus{MaxMem: 8 * gib, Mem: 3 * gib},nil,8*gib,"",&VMMemoryRaw{},)- if total != 8*gib || used != 0 || source != "rrd-memused" {- t.Fatalf("resolved memory = total %d used %d source %q, want idle RRD sample", total, used, source)+ if total != 8*gib || used != 3*gib || source != "status-mem" {+ t.Fatalf("resolved memory = total %d used %d source %q, want low-trust status-mem", total, used, source)+ }+ if client.rrdCalls != 0 {+ t.Fatalf("expected no guest RRD lookups, got %d", client.rrdCalls)}}@@ -121,7 +93,6 @@ func TestResolveGuestStatusMemoryAcceptsExplicitZeroGuestAgentAvailable(t *testiconst gib = uint64(1024 * 1024 * 1024)mon := &Monitor{- vmRRDMemCache: make(map[string]rrdMemCacheEntry),vmAgentMemCache: make(map[string]agentMemCacheEntry),}client := &guestMemoryAgentTestClient{@@ -277,7 +248,6 @@ func TestResolveGuestStatusMemoryUsesGuestAgentMeminfoFallback(t *testing.T) {const giB = uint64(1024 * 1024 * 1024)mon := &Monitor{- vmRRDMemCache: make(map[string]rrdMemCacheEntry),vmAgentMemCache: make(map[string]agentMemCacheEntry),}client := &guestMemoryAgentTestClient{@@ -327,12 +297,10 @@ func TestResolveGuestStatusMemoryPrefersGuestAgentMeminfoForSaturatedStatus(t *tconst giB = uint64(1024 * 1024 * 1024)mon := &Monitor{- vmRRDMemCache: make(map[string]rrdMemCacheEntry),vmAgentMemCache: make(map[string]agentMemCacheEntry),}client := &guestMemoryAgentTestClient{stubPVEClient: &stubPVEClient{},- vmRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(512 * 1024 * 1024))}},memAvailable: 4 * giB,}raw := &VMMemoryRaw{}diff --git a/internal/monitoring/guest_memory_sources.go b/internal/monitoring/guest_memory_sources.goindex e5330f27ca..605c83d1a3 100644--- a/internal/monitoring/guest_memory_sources.go+++ b/internal/monitoring/guest_memory_sources.go@@ -306,46 +306,10 @@ func (m *Monitor) resolveGuestStatusMemory(}}- if !hasMemAvailable {- if rrdMemory, rrdErr := m.getVMRRDMemory(ctx, client, instanceName, node, vmid); rrdErr == nil {- if guestRaw != nil {- guestRaw.RRDMemAvailable = rrdMemory.available- guestRaw.RRDMemUsed = rrdMemory.used- guestRaw.RRDMaxMem = rrdMemory.total- }- switch {- case rrdMemory.hasAvail && rrdMemory.available <= memTotal:- memAvailable = rrdMemory.available- hasMemAvailable = true- memorySource = "rrd-memavailable"- log.Debug().- Str("vm", guestName).- Str("node", node).- Int("vmid", vmid).- Uint64("total", memTotal).- Uint64("available", memAvailable).- Msg("QEMU memory: using RRD memavailable fallback")- case rrdMemory.hasUsed && rrdMemory.used <= memTotal:- selectedUsed = rrdMemory.used- hasSelectedUsed = true- memorySource = "rrd-memused"- log.Debug().- Str("vm", guestName).- Str("node", node).- Int("vmid", vmid).- Uint64("total", memTotal).- Uint64("used", rrdMemory.used).- Msg("QEMU memory: using RRD memused fallback")- }- } else if rrdErr != nil {- log.Debug().- Err(rrdErr).- Str("instance", instanceName).- Str("vm", guestName).- Int("vmid", vmid).- Msg("RRD memory data unavailable for VM, using status/cluster resources values")- }- }+ // No RRD fallback here: PVE guest rrddata carries only cache-inclusive+ // mem/maxmem columns — the cache-aware memused/memavailable columns exist+ // only in node RRD, so a guest RRD lookup can never yield memory evidence+ // (#1634).if !hasMemAvailable && !hasSelectedUsed && status.Agent.IsAvailable() && !triedGuestAgentMemAvailable {if agentAvailable, agentSource, ok := m.tryGuestAgentMemAvailable(ctx, client, instanceName, guestName, node, vmid, memTotal, guestRaw); ok {diff --git a/internal/monitoring/guest_memory_stability.go b/internal/monitoring/guest_memory_stability.goindex a4e5466905..7945594899 100644--- a/internal/monitoring/guest_memory_stability.go+++ b/internal/monitoring/guest_memory_stability.go@@ -20,7 +20,7 @@ const (func guestMemorySourceReliability(source string) int {switch CanonicalMemorySource(source) {case "available-field", "derived-free-buffers-cached",- "guest-agent-meminfo", "guest-agent-meminfo-derived", "rrd-memavailable", "rrd-memused", "agent":+ "guest-agent-meminfo", "guest-agent-meminfo-derived", "agent":return guestMemoryReliabilityTrustedcase "derived-total-minus-used", "previous-snapshot":return guestMemoryReliabilityFallbackdiff --git a/internal/monitoring/guest_memory_stability_test.go b/internal/monitoring/guest_memory_stability_test.goindex dd91b29b6e..f5aadddb7e 100644--- a/internal/monitoring/guest_memory_stability_test.go+++ b/internal/monitoring/guest_memory_stability_test.go@@ -16,7 +16,7 @@ func TestStabilizeGuestLowTrustMemoryCarriesForwardTrustedSnapshot(t *testing.T)prev := &GuestMemorySnapshot{Status: "running",RetrievedAt: now.Add(-time.Minute),- MemorySource: "rrd-memavailable",+ MemorySource: "guest-agent-meminfo",Memory: models.Memory{Total: 8 * int64(gib),Used: 3 * int64(gib),diff --git a/internal/monitoring/harness_integration.go b/internal/monitoring/harness_integration.goindex 179f05a661..343d5532ad 100644--- a/internal/monitoring/harness_integration.go+++ b/internal/monitoring/harness_integration.go@@ -383,12 +383,6 @@ func (noopPVEClient) GetNodeStatus(ctx context.Context, node string) (*proxmox.Nfunc (noopPVEClient) GetNodeRRDData(ctx context.Context, node string, timeframe string, cf string, ds []string) ([]proxmox.NodeRRDPoint, error) {return nil, nil}-func (noopPVEClient) GetLXCRRDData(ctx context.Context, node string, vmid int, timeframe string, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {- return nil, nil-}-func (noopPVEClient) GetVMRRDData(ctx context.Context, node string, vmid int, timeframe string, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {- return nil, nil-}func (noopPVEClient) GetVMs(ctx context.Context, node string) ([]proxmox.VM, error) { return nil, nil }func (noopPVEClient) GetContainers(ctx context.Context, node string) ([]proxmox.Container, error) {return nil, nildiff --git a/internal/monitoring/memory_trust_characterization_test.go b/internal/monitoring/memory_trust_characterization_test.goindex 46cedc101d..f09779a5f3 100644--- a/internal/monitoring/memory_trust_characterization_test.go+++ b/internal/monitoring/memory_trust_characterization_test.go@@ -15,8 +15,6 @@ type vmMemoryTrustStubClient struct {vms []proxmox.VMcontainers []proxmox.ContainervmStatus *proxmox.VMStatus- vmRRDPoints []proxmox.GuestRRDPoint- lxcRRDPoints []proxmox.GuestRRDPointvmAgentMemAvailable uint64vmRRDCalls intvmAgentMemCalls int@@ -66,13 +64,12 @@ func (s *vmMemoryTrustStubClient) GetVMStatus(ctx context.Context, node string,return s.vmStatus, nil}+// GetVMRRDData tracks lookups of the guest RRD endpoint. It is intentionally+// not part of PVEClientInterface anymore: guest rrddata carries no cache-aware+// memory columns (#1634), so the memory resolvers must never consult it.func (s *vmMemoryTrustStubClient) GetVMRRDData(ctx context.Context, node string, vmid int, timeframe, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {s.vmRRDCalls++- return s.vmRRDPoints, nil-}--func (s *vmMemoryTrustStubClient) GetLXCRRDData(ctx context.Context, node string, vmid int, timeframe, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {- return s.lxcRRDPoints, nil+ return nil, nil}func (s *vmMemoryTrustStubClient) GetVMMemAvailableFromAgent(ctx context.Context, node string, vmid int) (uint64, error) {@@ -364,17 +361,14 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {tests := []struct {name stringstatus *proxmox.VMStatus- rrdAvailable uint64- rrdUsed uint64agentAvailable uint64wantSource stringwantUsed uint64- wantAvailable uint64wantGap uint64wantUnknown bool}{{- name: "cache inflated Linux VM usage prefers RRD memavailable fallback",+ name: "cache inflated Linux VM with bare meminfo total stays unknown",status: &proxmox.VMStatus{Status: "running",MaxMem: 8 * gib,@@ -384,10 +378,8 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {},Agent: proxmox.VMAgentField{Value: 1},},- rrdAvailable: 4 * gib,- wantSource: "rrd-memavailable",- wantUsed: 4 * gib,- wantAvailable: 4 * gib,+ wantSource: "unavailable",+ wantUnknown: true,},{name: "missing MemAvailable derives from free buffers cached",@@ -423,22 +415,6 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {wantUsed: 5 * gib,wantGap: 3 * gib,},- {- name: "partial Linux meminfo uses RRD memused",- status: &proxmox.VMStatus{- Status: "running",- MaxMem: 8 * gib,- Mem: 7 * gib,- MemInfo: &proxmox.VMMemInfo{- Total: 8 * gib,- Free: gib / 2,- },- Agent: proxmox.VMAgentField{Value: 1},- },- rrdUsed: 5 * gib,- wantSource: "rrd-memused",- wantUsed: 5 * gib,- },{name: "partial Linux meminfo without cache aware fallback stays unknown",status: &proxmox.VMStatus{@@ -500,25 +476,6 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {wantSource: "unavailable",wantUnknown: true,},- {- name: "RRD available wins over delayed total minus used estimate",- status: &proxmox.VMStatus{- Status: "running",- MaxMem: 8 * gib,- Mem: 7 * gib,- MemInfo: &proxmox.VMMemInfo{- Total: 8 * gib,- Used: 5 * gib,- Free: gib / 2,- },- Agent: proxmox.VMAgentField{Value: 1},- },- rrdAvailable: 4 * gib,- wantSource: "rrd-memavailable",- wantUsed: 4 * gib,- wantAvailable: 4 * gib,- wantGap: 3 * gib,- },{name: "materially inconsistent status memory prefers freemem fallback",status: &proxmox.VMStatus{@@ -569,11 +526,6 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {vmStatus: tt.status,vmAgentMemAvailable: tt.agentAvailable,}- if tt.rrdAvailable > 0 {- client.vmRRDPoints = []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(tt.rrdAvailable))}}- } else if tt.rrdUsed > 0 {- client.vmRRDPoints = []proxmox.GuestRRDPoint{{MemUsed: floatPtr(float64(tt.rrdUsed))}}- }res := proxmox.ClusterResource{ID: "qemu/101",@@ -605,12 +557,6 @@ func TestHandleClusterVMResourceMemoryTrustCharacterization(t *testing.T) {if tt.wantSource == "derived-total-minus-used" && snap.FallbackReason != "derived-total-minus-used" {t.Fatalf("snapshot.FallbackReason = %q, want derived-total-minus-used", snap.FallbackReason)}- if tt.wantAvailable > 0 && snap.Raw.RRDMemAvailable != tt.wantAvailable {- t.Fatalf("snapshot.Raw.RRDMemAvailable = %d, want %d", snap.Raw.RRDMemAvailable, tt.wantAvailable)- }- if tt.rrdUsed > 0 && snap.Raw.RRDMemUsed != tt.rrdUsed {- t.Fatalf("snapshot.Raw.RRDMemUsed = %d, want %d", snap.Raw.RRDMemUsed, tt.rrdUsed)- }if tt.wantGap > 0 && snap.Raw.MemInfoTotalMinusUsed != tt.wantGap {t.Fatalf("snapshot.Raw.MemInfoTotalMinusUsed = %d, want %d", snap.Raw.MemInfoTotalMinusUsed, tt.wantGap)}@@ -635,7 +581,6 @@ func TestHandleClusterVMResourcePrefersGuestAgentMemAvailableForSaturatedIssue13Mem: 16*gib + 512*1024*1024,Agent: proxmox.VMAgentField{Value: 1},},- vmRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(512 * 1024 * 1024))}},vmAgentMemAvailable: 4 * gib,}res := proxmox.ClusterResource{@@ -769,15 +714,13 @@ func TestPollVMsWithNodesMemoryTrustCharacterization(t *testing.T) {const gib = uint64(1024 * 1024 * 1024)tests := []struct {- name string- status *proxmox.VMStatus- rrdAvailable uint64- wantSource string- wantUsed uint64- wantAvailable uint64+ name string+ status *proxmox.VMStatus+ wantSource string+ wantUsed uint64}{{- name: "cache inflated Linux VM usage prefers RRD memavailable fallback",+ name: "cache inflated Linux VM with bare meminfo total stays unknown",status: &proxmox.VMStatus{Status: "running",MaxMem: 8 * gib,@@ -787,10 +730,8 @@ func TestPollVMsWithNodesMemoryTrustCharacterization(t *testing.T) {},Agent: proxmox.VMAgentField{Value: 1},},- rrdAvailable: 4 * gib,- wantSource: "rrd-memavailable",- wantUsed: 4 * gib,- wantAvailable: 4 * gib,+ wantSource: "unavailable",+ wantUsed: 0,},{name: "missing Buffers and Cached derives from total minus used gap",@@ -852,9 +793,6 @@ func TestPollVMsWithNodesMemoryTrustCharacterization(t *testing.T) {}},vmStatus: tt.status,}- if tt.rrdAvailable > 0 {- client.vmRRDPoints = []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(tt.rrdAvailable))}}- }nodes := []proxmox.Node{{Node: "node1", Status: "online"}}nodeEffectiveStatus := map[string]string{"node1": "online"}@@ -871,9 +809,6 @@ func TestPollVMsWithNodesMemoryTrustCharacterization(t *testing.T) {if got := uint64(snap.Memory.Used); got != tt.wantUsed {t.Fatalf("snapshot.Memory.Used = %d, want %d", got, tt.wantUsed)}- if tt.wantAvailable > 0 && snap.Raw.RRDMemAvailable != tt.wantAvailable {- t.Fatalf("snapshot.Raw.RRDMemAvailable = %d, want %d", snap.Raw.RRDMemAvailable, tt.wantAvailable)- }if tt.wantSource == "derived-total-minus-used" && snap.FallbackReason != "derived-total-minus-used" {t.Fatalf("snapshot.FallbackReason = %q, want derived-total-minus-used", snap.FallbackReason)}@@ -988,72 +923,15 @@ func TestHandleClusterContainerResourceMemoryTrustCharacterization(t *testing.T)const gib = uint64(1024 * 1024 * 1024)tests := []struct {- name string- res proxmox.ClusterResource- lxcRRDPoints []proxmox.GuestRRDPoint- wantSource string- wantUsed uint64- wantAvail uint64- wantStatus string- wantUnknown bool+ name string+ res proxmox.ClusterResource+ wantSource string+ wantUsed uint64+ wantStatus string+ wantUnknown bool}{{- name: "cache inflated LXC usage prefers RRD memavailable fallback",- res: proxmox.ClusterResource{- ID: "lxc/201",- Type: "lxc",- Node: "node1",- Name: "ct-201",- Status: "running",- VMID: 201,- MaxMem: 8 * gib,- Mem: 7 * gib,- MaxCPU: 4,- },- lxcRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(3 * gib))}},- wantSource: "rrd-memavailable",- wantUsed: 5 * gib,- wantAvail: 3 * gib,- wantStatus: "running",- },- {- name: "missing memavailable falls back to RRD memused",- res: proxmox.ClusterResource{- ID: "lxc/202",- Type: "lxc",- Node: "node1",- Name: "ct-202",- Status: "running",- VMID: 202,- MaxMem: 8 * gib,- Mem: 7 * gib,- MaxCPU: 4,- },- lxcRRDPoints: []proxmox.GuestRRDPoint{{MemUsed: floatPtr(float64(6 * gib))}},- wantSource: "rrd-memused",- wantUsed: 6 * gib,- wantStatus: "running",- },- {- name: "explicit zero RRD memavailable is valid full usage",- res: proxmox.ClusterResource{- ID: "lxc/205",- Type: "lxc",- Node: "node1",- Name: "ct-205",- Status: "running",- VMID: 205,- MaxMem: 8 * gib,- Mem: 7 * gib,- MaxCPU: 4,- },- lxcRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(0)}},- wantSource: "rrd-memavailable",- wantUsed: 8 * gib,- wantStatus: "running",- },- {- name: "running LXC without RRD memory falls back to cluster resources (#1634)",+ name: "running LXC uses the cache-inclusive cluster resources listing (#1634)",res: proxmox.ClusterResource{ID: "lxc/204",Type: "lxc",@@ -1070,7 +948,7 @@ func TestHandleClusterContainerResourceMemoryTrustCharacterization(t *testing.T)wantStatus: "running",},{- name: "running LXC without RRD memory or listing value stays unknown",+ name: "running LXC without a listing memory value stays unknown",res: proxmox.ClusterResource{ID: "lxc/206",Type: "lxc",@@ -1113,7 +991,6 @@ func TestHandleClusterContainerResourceMemoryTrustCharacterization(t *testing.T)client := &vmMemoryTrustStubClient{stubPVEClient: &stubPVEClient{},}- client.lxcRRDPoints = tt.lxcRRDPointscontainer, ok := mon.handleClusterContainerResource(context.Background(),@@ -1147,9 +1024,6 @@ func TestHandleClusterContainerResourceMemoryTrustCharacterization(t *testing.T)if got := uint64(snap.Memory.Used); got != tt.wantUsed {t.Fatalf("snapshot.Memory.Used = %d, want %d", got, tt.wantUsed)}- if tt.wantAvail > 0 && snap.Raw.RRDMemAvailable != tt.wantAvail {- t.Fatalf("snapshot.Raw.RRDMemAvailable = %d, want %d", snap.Raw.RRDMemAvailable, tt.wantAvail)- }})}}@@ -1194,15 +1068,13 @@ func TestPollContainersWithNodesMemoryTrustCharacterization(t *testing.T) {const gib = uint64(1024 * 1024 * 1024)tests := []struct {- name string- container proxmox.Container- lxcRRDPoints []proxmox.GuestRRDPoint- wantSource string- wantUsed uint64- wantAvail uint64+ name string+ container proxmox.Container+ wantSource string+ wantUsed uint64}{{- name: "running LXC prefers RRD memavailable in node polling",+ name: "running LXC uses the cluster resources listing in node polling (#1634)",container: proxmox.Container{VMID: 301,Name: "ct-301",@@ -1212,10 +1084,8 @@ func TestPollContainersWithNodesMemoryTrustCharacterization(t *testing.T) {Mem: 7 * gib,CPUs: 2,},- lxcRRDPoints: []proxmox.GuestRRDPoint{{MemAvailable: floatPtr(float64(3 * gib))}},- wantSource: "rrd-memavailable",- wantUsed: 5 * gib,- wantAvail: 3 * gib,+ wantSource: "cluster-resources",+ wantUsed: 7 * gib,},{name: "stopped LXC reports powered off memory in node polling",@@ -1242,7 +1112,6 @@ func TestPollContainersWithNodesMemoryTrustCharacterization(t *testing.T) {client := &vmMemoryTrustStubClient{stubPVEClient: &stubPVEClient{},containers: []proxmox.Container{tt.container},- lxcRRDPoints: tt.lxcRRDPoints,}nodes := []proxmox.Node{{Node: "node1", Status: "online"}}@@ -1260,9 +1129,6 @@ func TestPollContainersWithNodesMemoryTrustCharacterization(t *testing.T) {if got := uint64(snap.Memory.Used); got != tt.wantUsed {t.Fatalf("snapshot.Memory.Used = %d, want %d", got, tt.wantUsed)}- if tt.wantAvail > 0 && snap.Raw.RRDMemAvailable != tt.wantAvail {- t.Fatalf("snapshot.Raw.RRDMemAvailable = %d, want %d", snap.Raw.RRDMemAvailable, tt.wantAvail)- }})}}diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex 34d607a898..11bd0ca3d9 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -70,8 +70,6 @@ type PVEClientInterface interface {GetNodes(ctx context.Context) ([]proxmox.Node, error)GetNodeStatus(ctx context.Context, node string) (*proxmox.NodeStatus, error)GetNodeRRDData(ctx context.Context, node string, timeframe string, cf string, ds []string) ([]proxmox.NodeRRDPoint, error)- GetLXCRRDData(ctx context.Context, node string, vmid int, timeframe string, cf string, ds []string) ([]proxmox.GuestRRDPoint, error)- GetVMRRDData(ctx context.Context, node string, vmid int, timeframe string, cf string, ds []string) ([]proxmox.GuestRRDPoint, error)GetVMs(ctx context.Context, node string) ([]proxmox.VM, error)GetContainers(ctx context.Context, node string) ([]proxmox.Container, error)GetStorage(ctx context.Context, node string) ([]proxmox.Storage, error)@@ -1117,7 +1115,6 @@ type Monitor struct {guestSnapshots map[string]GuestMemorySnapshotrrdCacheMu sync.RWMutex // Protects short-lived guest memory caches.nodeRRDMemCache map[string]rrdMemCacheEntry- vmRRDMemCache map[string]rrdMemCacheEntryvmAgentMemCache map[string]agentMemCacheEntryremovedDockerHosts map[string]time.Time // Track deliberately removed Docker hosts (ID -> removal time)dockerTokenBindings map[string]string // Track token ID -> Docker host identity bindings to enforce uniqueness@@ -1402,100 +1399,6 @@ func (m *Monitor) getNodeRRDMetrics(ctx context.Context, client PVEClientInterfareturn entry, nil}-// getVMRRDMetrics fetches Proxmox RRD memavailable for a single VM with a-// short-lived cache to avoid a live API call on every poll for VMs that-// consistently lack guest-agent memory data (e.g. Windows VMs).-func (m *Monitor) getVMRRDMetrics(ctx context.Context, client PVEClientInterface, instanceName, node string, vmid int) (uint64, error) {- entry, err := m.getVMRRDMemory(ctx, client, instanceName, node, vmid)- if err != nil {- return 0, err- }- if !entry.hasAvail {- return 0, fmt.Errorf("rrd memavailable not present for VM %s/%d", node, vmid)- }- return entry.available, nil-}--func (m *Monitor) getVMRRDMemory(ctx context.Context, client PVEClientInterface, instanceName, node string, vmid int) (rrdMemCacheEntry, error) {- if client == nil || node == "" || vmid <= 0 {- return rrdMemCacheEntry{}, fmt.Errorf("invalid arguments for VM RRD lookup")- }-- cacheKey := guestMemoryCacheKey(instanceName, node, vmid)- now := time.Now()-- m.rrdCacheMu.RLock()- if entry, ok := m.vmRRDMemCache[cacheKey]; ok && now.Sub(entry.fetchedAt) < nodeRRDCacheTTL {- m.rrdCacheMu.RUnlock()- return entry, nil- }- m.rrdCacheMu.RUnlock()-- requestCtx, cancel := context.WithTimeout(ctx, nodeRRDRequestTimeout)- defer cancel()-- points, err := client.GetVMRRDData(requestCtx, node, vmid, "hour", "AVERAGE", []string{"memavailable", "memused", "maxmem"})- if err != nil {- return rrdMemCacheEntry{}, err- }- if len(points) == 0 {- return rrdMemCacheEntry{}, fmt.Errorf("no RRD points for VM %s/%d", node, vmid)- }-- var memAvailable uint64- var memUsed uint64- var memTotal uint64- var hasAvail bool- var hasUsed bool- var hasTotal bool- for i := len(points) - 1; i >= 0; i-- {- p := points[i]- if !hasAvail && p.MemAvailable != nil && !math.IsNaN(*p.MemAvailable) && !math.IsInf(*p.MemAvailable, 0) && *p.MemAvailable >= 0 && *p.MemAvailable <= math.MaxUint64 {- memAvailable = uint64(math.Round(*p.MemAvailable))- hasAvail = true- }- if !hasUsed && p.MemUsed != nil && !math.IsNaN(*p.MemUsed) && !math.IsInf(*p.MemUsed, 0) && *p.MemUsed >= 0 && *p.MemUsed <= math.MaxUint64 {- memUsed = uint64(math.Round(*p.MemUsed))- hasUsed = true- }- if !hasTotal && p.MaxMem != nil && !math.IsNaN(*p.MaxMem) && !math.IsInf(*p.MaxMem, 0) && *p.MaxMem > 0 && *p.MaxMem <= math.MaxUint64 {- memTotal = uint64(math.Round(*p.MaxMem))- hasTotal = true- }- }- if hasTotal {- if hasAvail && memAvailable > memTotal {- hasAvail = false- memAvailable = 0- }- if hasUsed && memUsed > memTotal {- hasUsed = false- memUsed = 0- }- }- if !hasAvail && !hasUsed {- return rrdMemCacheEntry{}, fmt.Errorf("rrd memory fields not present for VM %s/%d", node, vmid)- }-- entry := rrdMemCacheEntry{- available: memAvailable,- used: memUsed,- total: memTotal,- hasAvail: hasAvail,- hasUsed: hasUsed,- hasTotal: hasTotal,- fetchedAt: now,- }- m.rrdCacheMu.Lock()- if m.vmRRDMemCache == nil {- m.vmRRDMemCache = make(map[string]rrdMemCacheEntry)- }- m.vmRRDMemCache[cacheKey] = entry- m.rrdCacheMu.Unlock()-- return entry, nil-}-// RemoveDockerHost removes a docker host from the shared state and clears related alerts.func (m *Monitor) GetConnectionStatuses() map[string]bool {if m == nil {@@ -1759,7 +1662,6 @@ func New(cfg *config.Config) (*Monitor, error) {nodeSnapshots: make(map[string]NodeMemorySnapshot),guestSnapshots: make(map[string]GuestMemorySnapshot),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),vmAgentMemCache: make(map[string]agentMemCacheEntry),removedDockerHosts: make(map[string]time.Time),dockerTokenBindings: make(map[string]string),diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.goindex 594e0a9a20..c95f32a2c6 100644--- a/internal/monitoring/monitor_agents.go+++ b/internal/monitoring/monitor_agents.go@@ -3838,12 +3838,6 @@ func (m *Monitor) cleanupRRDCache(now time.Time) {}}- for key, entry := range m.vmRRDMemCache {- if now.Sub(entry.fetchedAt) > maxAge {- delete(m.vmRRDMemCache, key)- }- }-for key, entry := range m.vmAgentMemCache {if now.Sub(entry.fetchedAt) > vmAgentMemCleanupMaxAge {delete(m.vmAgentMemCache, key)diff --git a/internal/monitoring/monitor_extra_coverage_test.go b/internal/monitoring/monitor_extra_coverage_test.goindex 7f37abf3fa..522255ab16 100644--- a/internal/monitoring/monitor_extra_coverage_test.go+++ b/internal/monitoring/monitor_extra_coverage_test.go@@ -682,7 +682,6 @@ func TestPollVMsWithNodesCompletesDiskQueriesWithinPollBudget(t *testing.T) {alertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),vmAgentMemCache: make(map[string]agentMemCacheEntry),guestAgentWorkSlots: make(chan struct{}, 3),}@@ -1401,7 +1400,6 @@ func TestPollVMsAndContainersEfficient_ContinuesGuestAgentQueriesAfterTransientSalertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),}defer m.alertManager.Stop()@@ -1505,7 +1503,6 @@ func TestPollVMsWithNodes_PreservesCachedGuestMetadataWhenStatusUnavailable(t *talertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),}defer m.alertManager.Stop()@@ -1575,7 +1572,6 @@ func TestPollVMsWithNodes_ContinuesGuestAgentQueriesAfterTransientStatusFailure(alertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),}defer m.alertManager.Stop()@@ -1988,7 +1984,6 @@ func TestPollVMsWithNodes_CarriesForwardPreviousDiskSnapshot(t *testing.T) {alertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),}defer m.alertManager.Stop()@@ -2066,7 +2061,6 @@ func TestPollVMsWithNodes_PrefersLinkedHostAgentDiskInventoryOverGuestAgentFilesalertManager: alerts.NewManager(),stalenessTracker: NewStalenessTracker(nil),nodeRRDMemCache: make(map[string]rrdMemCacheEntry),- vmRRDMemCache: make(map[string]rrdMemCacheEntry),}defer m.alertManager.Stop()diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.goindex 5d681fe2b1..6165b0016a 100644--- a/internal/monitoring/monitor_host_agents_test.go+++ b/internal/monitoring/monitor_host_agents_test.go@@ -4295,3 +4295,37 @@ func TestConfiguredHostIPs_UnresolvableHostDoesNotDropOthers(t *testing.T) {t.Fatalf("configured host IPs = %v, want only the resolvable host [192.0.2.30]", ips)}}++// cleanupRRDCache is part of monitor housekeeping for agent-derived memory+// evidence. After the dead guest RRD memory cache was removed (#1634), the+// short-lived caches it prunes are the node RRD cache and the guest-agent+// meminfo cache; stale guest-agent entries must age out so removed or+// re-enrolled guests cannot replay old agent memory evidence.+func TestCleanupRRDCachePrunesStaleGuestAgentMemCache(t *testing.T) {+ now := time.Now()+ m := &Monitor{+ nodeRRDMemCache: map[string]rrdMemCacheEntry{+ "inst/node-stale": {fetchedAt: now.Add(-3 * nodeRRDCacheTTL)},+ "inst/node-fresh": {fetchedAt: now},+ },+ vmAgentMemCache: map[string]agentMemCacheEntry{+ "inst/node/100": {fetchedAt: now.Add(-vmAgentMemCleanupMaxAge - time.Second)},+ "inst/node/101": {fetchedAt: now},+ },+ }++ m.cleanupRRDCache(now)++ if _, ok := m.nodeRRDMemCache["inst/node-stale"]; ok {+ t.Error("stale node RRD cache entry not pruned")+ }+ if _, ok := m.nodeRRDMemCache["inst/node-fresh"]; !ok {+ t.Error("fresh node RRD cache entry pruned")+ }+ if _, ok := m.vmAgentMemCache["inst/node/100"]; ok {+ t.Error("stale guest-agent meminfo cache entry not pruned")+ }+ if _, ok := m.vmAgentMemCache["inst/node/101"]; !ok {+ t.Error("fresh guest-agent meminfo cache entry pruned")+ }+}diff --git a/internal/monitoring/monitor_polling_containers.go b/internal/monitoring/monitor_polling_containers.goindex a5fbe9c431..d97cd72a81 100644--- a/internal/monitoring/monitor_polling_containers.go+++ b/internal/monitoring/monitor_polling_containers.go@@ -145,7 +145,7 @@ func (m *Monitor) collectContainersWithNodes(ctx context.Context, instanceName scpuUsage = 0}- memTotal, memUsed, memorySource, guestRaw := m.calculateLXCMemory(ctx, instanceName, proxmox.ClusterResource{+ memTotal, memUsed, memorySource, guestRaw := m.calculateLXCMemory(proxmox.ClusterResource{Type: "lxc",Node: n.Node,Name: container.Name,@@ -153,7 +153,7 @@ func (m *Monitor) collectContainersWithNodes(ctx context.Context, instanceName sVMID: int(container.VMID),MaxMem: container.MaxMem,Mem: container.Mem,- }, client)+ })memUsed, memorySource, _ = stabilizeGuestLowTrustMemory(m.previousGuestSnapshot(instanceName, "lxc", n.Node, int(container.VMID)),container.Status,diff --git a/internal/monitoring/monitor_pve_guest_lxc.go b/internal/monitoring/monitor_pve_guest_lxc.goindex feb4b0d7d0..a827708ae1 100644--- a/internal/monitoring/monitor_pve_guest_lxc.go+++ b/internal/monitoring/monitor_pve_guest_lxc.go@@ -2,7 +2,6 @@ package monitoringimport ("context"- "math""strings""time"@@ -12,14 +11,14 @@ import ()func (m *Monitor) calculateLXCMemory(- ctx context.Context,- instanceName string,res proxmox.ClusterResource,- client PVEClientInterface,) (uint64, uint64, string, VMMemoryRaw) {- // Calculate cache-aware memory for LXC containers- // The cluster resources API returns mem from cgroup which includes cache/buffers (inflated).- // Try to get more accurate memory metrics from RRD data.+ // The cluster resources API returns mem from cgroup which includes+ // cache/buffers (inflated). PVE guest RRD offers nothing better: it+ // carries only the same cache-inclusive mem/maxmem columns — the+ // cache-aware memused/memavailable columns exist only in node RRD — so+ // the listing value is the best evidence available for running+ // containers (issue #1634).memTotal := res.MaxMemmemUsed := uint64(0)memorySource := "powered-off"@@ -28,66 +27,9 @@ func (m *Monitor) calculateLXCMemory(ListingMaxMem: res.MaxMem,}- // For running containers, try to get RRD data for cache-aware memory calculationif res.Status == "running" {memorySource = "unavailable"- rrdCtx, rrdCancel := context.WithTimeout(ctx, 5*time.Second)- rrdPoints, err := client.GetLXCRRDData(rrdCtx, res.Node, res.VMID, "hour", "AVERAGE", []string{"memavailable", "memused", "maxmem"})- rrdCancel()-- if err == nil && len(rrdPoints) > 0 {- // Use the most recent RRD point- point := rrdPoints[len(rrdPoints)-1]-- if point.MaxMem != nil && !math.IsNaN(*point.MaxMem) && !math.IsInf(*point.MaxMem, 0) && *point.MaxMem > 0 && *point.MaxMem <= math.MaxUint64 {- guestRaw.RRDMaxMem = uint64(*point.MaxMem)- if memTotal == 0 {- memTotal = uint64(*point.MaxMem)- }- }-- // Prefer memavailable-based calculation (excludes cache/buffers)- if point.MemAvailable != nil && !math.IsNaN(*point.MemAvailable) && !math.IsInf(*point.MemAvailable, 0) && *point.MemAvailable >= 0 && *point.MemAvailable <= math.MaxUint64 && memTotal > 0 && *point.MemAvailable <= float64(memTotal) {- memAvailable := uint64(*point.MemAvailable)- memUsed = memTotal - memAvailable- memorySource = "rrd-memavailable"- guestRaw.RRDMemAvailable = memAvailable- log.Debug().- Str("container", res.Name).- Str("node", res.Node).- Uint64("total", memTotal).- Uint64("available", memAvailable).- Uint64("used", memUsed).- Float64("usage", safePercentage(float64(memUsed), float64(memTotal))).- Msg("LXC memory: using RRD memavailable (excludes reclaimable cache)")- } else if point.MemUsed != nil && !math.IsNaN(*point.MemUsed) && !math.IsInf(*point.MemUsed, 0) && *point.MemUsed >= 0 && *point.MemUsed <= math.MaxUint64 && memTotal > 0 && *point.MemUsed <= float64(memTotal) {- // Fall back to memused from RRD if available- memUsed = uint64(*point.MemUsed)- memorySource = "rrd-memused"- guestRaw.RRDMemUsed = memUsed- log.Debug().- Str("container", res.Name).- Str("node", res.Node).- Uint64("total", memTotal).- Uint64("used", memUsed).- Float64("usage", safePercentage(float64(memUsed), float64(memTotal))).- Msg("LXC memory: using RRD memused (excludes reclaimable cache)")- }- } else if err != nil {- log.Debug().- Err(err).- Str("instance", instanceName).- Str("container", res.Name).- Int("vmid", res.VMID).- Msg("RRD memory data unavailable for LXC; falling back to cluster resources value")- }-- // PVE guest RRD carries only mem/maxmem columns (cgroup values, cache- // included) — the cache-aware memused/memavailable columns exist only- // in node RRD, so the branches above cannot match a real response.- // Without this fallback every running container reports unavailable- // memory (issue #1634).- if memorySource == "unavailable" && res.Mem > 0 {+ if res.Mem > 0 {memUsed = res.MemmemorySource = "cluster-resources"}@@ -145,7 +87,7 @@ func (m *Monitor) buildContainerFromClusterResource(netOutRate,)- memTotal, memUsed, memorySource, guestRaw := m.calculateLXCMemory(ctx, instanceName, res, client)+ memTotal, memUsed, memorySource, guestRaw := m.calculateLXCMemory(res)memUsed, memorySource, _ = stabilizeGuestLowTrustMemory(m.previousGuestSnapshot(instanceName, "lxc", res.Node, res.VMID),res.Status,diff --git a/internal/monitoring/monitor_pve_guest_lxc_test.go b/internal/monitoring/monitor_pve_guest_lxc_test.goindex 7678d8f15f..d3197fe9fa 100644--- a/internal/monitoring/monitor_pve_guest_lxc_test.go+++ b/internal/monitoring/monitor_pve_guest_lxc_test.go@@ -179,27 +179,27 @@ func TestBuildContainerFromClusterResource_UsesContainerStatusCountersForRates(ttype stubPVEClientLXCRRD struct {stubPVEClient- lxcRRDPoints []proxmox.GuestRRDPoint- lxcRRDErr error+ lxcRRDCalls int}+// GetLXCRRDData tracks lookups of the guest RRD endpoint. It is intentionally+// not part of PVEClientInterface anymore: guest rrddata carries only the+// cache-inclusive mem/maxmem columns (#1634), so the LXC memory path must not+// consult it.func (s *stubPVEClientLXCRRD) GetLXCRRDData(ctx context.Context, node string, vmid int, timeframe, cf string, ds []string) ([]proxmox.GuestRRDPoint, error) {- return s.lxcRRDPoints, s.lxcRRDErr+ s.lxcRRDCalls+++ return nil, nil}// Issue #1634: real PVE guest RRD responses carry only mem/maxmem, never the-// cache-aware memused/memavailable columns, so running containers must fall-// back to the cluster-resources listing value instead of reporting memory as-// unavailable (rendered as 0%).+// cache-aware memused/memavailable columns, so running containers use the+// cluster-resources listing value instead of reporting memory as unavailable+// (rendered as 0%). The guest RRD lookup is gone entirely — it could never+// produce memory evidence.func TestIssue1634LXCMemoryFallsBackToClusterResourcesOnRealRRDShape(t *testing.T) {t.Parallel()- maxMem := float64(8 * 1024 * 1024 * 1024)- client := &stubPVEClientLXCRRD{- lxcRRDPoints: []proxmox.GuestRRDPoint{- {Time: 1785164640, MaxMem: &maxMem},- },- }+ client := &stubPVEClientLXCRRD{}monitor := &Monitor{rateTracker: NewRateTracker()}resource := proxmox.ClusterResource{@@ -237,39 +237,8 @@ func TestIssue1634LXCMemoryFallsBackToClusterResourcesOnRealRRDShape(t *testing.if !container.Memory.HasKnownUsage() {t.Fatal("expected fallback memory to be usable for projections")}-}--func TestIssue1634LXCMemoryFallsBackWhenRRDErrors(t *testing.T) {- t.Parallel()-- client := &stubPVEClientLXCRRD{lxcRRDErr: context.DeadlineExceeded}-- monitor := &Monitor{rateTracker: NewRateTracker()}- resource := proxmox.ClusterResource{- Type: "lxc",- Node: "pve-a",- Name: "issue1634-rrd-err",- Status: "running",- VMID: 109,- MaxMem: 512 * 1024 * 1024,- Mem: 113344512,- }-- container, _, memorySource, _, ok := monitor.buildContainerFromClusterResource(- context.Background(),- "cluster-a",- resource,- client,- map[int]bool{},- )- if !ok {- t.Fatal("expected container sample to be built")- }- if CanonicalMemorySource(memorySource) != "cluster-resources" {- t.Fatalf("memory source = %q, want cluster-resources fallback", memorySource)- }- if container.Memory.Used != int64(resource.Mem) || container.Memory.UsageUnavailable {- t.Fatalf("memory = %+v, want listing fallback", container.Memory)+ if client.lxcRRDCalls != 0 {+ t.Fatalf("expected no guest RRD lookups for LXC memory, got %d", client.lxcRRDCalls)}}diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.goindex c6a577f89f..6f8fd1c999 100644--- a/internal/unifiedresources/code_standards_test.go+++ b/internal/unifiedresources/code_standards_test.go@@ -69,6 +69,7 @@ import ("time""github.com/rcourtman/pulse-go-rewrite/internal/models"+ "github.com/rcourtman/pulse-go-rewrite/pkg/proxmox")func TestMetricValueAlwaysCarriesNumericValueWhenObjectExists(t *testing.T) {@@ -2762,3 +2763,22 @@ func TestCloneVMwareDataKeepsNestedRuntimeDetailsIsolated(t *testing.T) {}}}++func TestGuestRRDPointCarriesOnlyRecordedGuestColumns(t *testing.T) {+ // Issue #1634: GuestRRDPoint once declared memused/memavailable columns+ // that real PVE guest rrddata responses never contain — they exist only+ // in node RRD — so every consumer branch reading them was dead and guest+ // memory silently fell through. The struct must not regrow columns that+ // are absent from the recorded fixtures in pkg/proxmox/testdata/rrd/.+ allowed := map[string]bool{"time": true, "maxmem": true}+ typ := reflect.TypeOf(proxmox.GuestRRDPoint{})+ for i := 0; i < typ.NumField(); i++ {+ tag := typ.Field(i).Tag.Get("json")+ if comma := strings.IndexByte(tag, ','); comma >= 0 {+ tag = tag[:comma]+ }+ if !allowed[tag] {+ t.Errorf("GuestRRDPoint field %s (json %q) is not a recorded guest rrddata column; add fixture evidence under pkg/proxmox/testdata/rrd before parsing it (#1634)", typ.Field(i).Name, tag)+ }+ }+}diff --git a/pkg/proxmox/client.go b/pkg/proxmox/client.goindex 1948649516..d217d7a3ab 100644--- a/pkg/proxmox/client.go+++ b/pkg/proxmox/client.go@@ -633,11 +633,11 @@ type NodeRRDPoint struct {}// GuestRRDPoint represents a single RRD datapoint for a VM or LXC container.+// Guest RRD carries only cache-inclusive mem/maxmem columns; the cache-aware+// memused/memavailable columns exist only in node RRD (#1634).type GuestRRDPoint struct {- Time int64 `json:"time"`- MaxMem *float64 `json:"maxmem,omitempty"`- MemUsed *float64 `json:"memused,omitempty"`- MemAvailable *float64 `json:"memavailable,omitempty"`+ Time int64 `json:"time"`+ MaxMem *float64 `json:"maxmem,omitempty"`}// NodeStatus represents detailed node status from /nodes/{node}/status endpointdiff --git a/pkg/proxmox/issue1634_rrd_fixture_test.go b/pkg/proxmox/issue1634_rrd_fixture_test.goindex 42131578ed..6da57ec17f 100644--- a/pkg/proxmox/issue1634_rrd_fixture_test.go+++ b/pkg/proxmox/issue1634_rrd_fixture_test.go@@ -19,17 +19,6 @@ import (// the real client and fail whenever a parsing struct references a column// absent from every recorded response.-// knownDeadGuestRRDFields are GuestRRDPoint columns that no recorded guest-// response (PVE 8 or PVE 9) contains. They only ever decode to nil; the-// consumers in internal/monitoring treat them as absent evidence (#1634).-// Removing them from GuestRRDPoint is a monitoring-subsystem runtime change-// (governance guard) tracked separately. Do not add entries here — a new-// struct field must reference a column present in the recorded fixtures.-var knownDeadGuestRRDFields = map[string]string{- "memused": "exists only in node RRD; guest responses report cache-inclusive mem/maxmem",- "memavailable": "exists only in PVE 9 node RRD; never present for guests",-}-func rrdFixturePath(name string) string {return filepath.Join("testdata", "rrd", name)}@@ -133,29 +122,9 @@ func TestGuestRRDPointColumnsExistInRecordedResponses(t *testing.T) {}}- tags := jsonFieldTags(t, reflect.TypeOf(GuestRRDPoint{}))- for _, tag := range tags {- if recorded[tag] {- continue- }- if _, dead := knownDeadGuestRRDFields[tag]; dead {- continue- }- t.Errorf("GuestRRDPoint field %q is absent from every recorded guest rrddata response; do not parse columns the PVE API does not send (#1634)", tag)- }-- // Keep the allowlist honest: entries must still be struct fields, and- // must still be absent from the recordings.- tagSet := make(map[string]bool, len(tags))- for _, tag := range tags {- tagSet[tag] = true- }- for column := range knownDeadGuestRRDFields {- if !tagSet[column] {- t.Errorf("knownDeadGuestRRDFields entry %q is no longer a GuestRRDPoint field; remove it from the allowlist", column)- }- if recorded[column] {- t.Errorf("knownDeadGuestRRDFields entry %q now appears in recorded responses; remove it from the allowlist and re-record fixtures", column)+ for _, tag := range jsonFieldTags(t, reflect.TypeOf(GuestRRDPoint{})) {+ if !recorded[tag] {+ t.Errorf("GuestRRDPoint field %q is absent from every recorded guest rrddata response; do not parse columns the PVE API does not send (#1634)", tag)}}}@@ -207,14 +176,6 @@ func TestGuestRRDDecodeAgainstRecordedResponses(t *testing.T) {if p.MaxMem != nil && *p.MaxMem > 0 {sawMaxMem = true}- // The #1634 mechanism: these columns never arrive for- // guests, so the fields can only ever be nil.- if p.MemUsed != nil {- t.Fatalf("MemUsed decoded from a recorded guest response (time=%d); guest RRD does not carry memused", p.Time)- }- if p.MemAvailable != nil {- t.Fatalf("MemAvailable decoded from a recorded guest response (time=%d); guest RRD does not carry memavailable", p.Time)- }}if !sawMaxMem {t.Fatal("no point carried maxmem; fixture should include populated rows")