mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-25 21:20:00 +00:00
7c29ec63e3
Commita5baa7563bstopped Patrol reading cache-inclusive Proxmox memory as guest pressure (issue #2762, a QEMU VM). It also put `cluster-resources` in that cache-inclusive group for every guest type. An LXC without a linked Pulse agent only ever gets `cluster-resources`, so Patrol dropped memory pressure for all agentless containers: - a container at 97% of its limit got no triage flag, forecast or anomaly - the seed said "guest pressure unknown; may include reclaimable cache" - older memory alerts went to a billed model review on every run, and any resolve verdict was thrown away **That premise is wrong for LXC.** On both PVE 9 (`master`) and PVE 8 (`stable-bookworm` / `stable-8`), Proxmox subtracts page cache before reporting a container's memory: - `pve-common` `src/PVE/CGroup.pm` `get_memory_stat`: `$res->{mem} = $mem - $stat->{file};` on cgroup v2 (`memory.current`), and `$res->{mem} = $mem - $stat->{total_cache};` on v1 (`memory.usage_in_bytes`). - `pve-container` `src/PVE/LXC.pm` `vmstatus` stores that value with `$d->{mem} = int($mem->{mem});`. `PVE::LXC::CGroup` inherits `get_memory_stat` from `PVE::CGroup` without overriding it. - `pve-manager` `pvestatd` `update_lxc_status` writes `$d->{mem}` into RRD field 8. `/cluster/resources` (`PVE/API2/Cluster.pm` → `PVE::API2Tools::extract_vm_stats`) returns `$entry->{mem} = ($d->[8] || 0) + 0;`. A QEMU guest's listing `mem` is the host's view of guest RAM, which does include the guest's cache, so it stays pressure-unknown. **Change** - `unifiedresources.QualifyGuestMemoryForKind` now takes the guest kind: other platform, Proxmox VM or Proxmox container. - A current, dated `cluster-resources` reading counts as known pressure for a Proxmox container and stays cache-inclusive and unknown for QEMU. - `status-mem`, `status-freemem` and `derived-total-minus-used` are unchanged for every guest type. - `GuestMemoryEvidenceForResource` takes the kind from the resource type, so the Patrol inventory, the observer runtime and AI query projections agree. - `QualifyGuestMemory(bool)` keeps the conservative QEMU reading for callers that don't know the guest type. - The wrong comments in `calculateLXCMemory` and the LXC monitor tests are corrected. - Everything else ina5baa7563bstill applies: retained, undated, unknown and unavailable readings still cannot establish pressure or recovery. **Tests** - `TestPatrolAgentlessLXCListingMemoryIsPressure` (new) builds an LXC and a QEMU guest at 97%, both on `cluster-resources`, through legacy and canonical read state. The LXC gets a memory triage flag and alert review reads its value; the QEMU guest gets neither. - `TestGuestMemoryClusterResourcesIsTypeAware` (new) covers both guest kinds, retained readings, the other cache-inclusive sources and the resource-type mapping. - The `cluster-cache` fixture in `TestPatrolGuestMemoryEvidence` now expects pressure for the container variant. It previously encoded the wrong behaviour. - Against origin/main's production files (`go test -overlay`), the new and updated Patrol tests fail; with this change they pass. Refs #2762 Supersedes #3011, which failed the documentation recipe test that pinned the old `QualifyGuestMemory(` call in Patrol; this commit also updates that pin to `QualifyGuestMemoryForKind(`.