fix(system): do not fail memory snapshots on inaccessible processes (#2078)
- `get_memory_info()` no longer raises when a process cannot be inspected. In restricted environments (`hidepid`, hardened containers) it failed on every sample, which meant a traceback in the log every second and an autoscaler running on a stale memory history. Processes that deny inspection, exit mid-measurement, or lose their `/proc` entry are now skipped instead. - Failure to list the child processes no longer aborts the snapshot either - the parent's own usage is still reported. - A kernel that exposes no `smaps` at all makes psutil alias `memory_full_info` to `memory_info`, whose result has no `pss` field, so reading it raised `AttributeError` on every sample. The metric is now read defensively, and the verdict is latched: such a machine is detected once instead of being re-probed for every process on every sample. - A `smaps` file can be empty, which psutil parses to a PSS of zero. That was reported as zero bytes used, which the autoscaler reads as free memory. A PSS of zero now falls back to the RSS of the same process, which `memory_full_info()` has already read anyway. - A single process denying PSS falls back to RSS just for itself - a denial says nothing about the other processes, so it is not latched. - Every degraded path warns once, so an estimate that misses a subprocess or falls back from PSS to RSS shows up in the log instead of being silently wrong. - `LoggerOnce` is now thread-safe, since memory metrics are sampled in a worker thread - this PR adds its first caller that runs off the event loop. - Nothing changes when PSS is readable: on a normal Linux process tree the reported `current_size` is byte-for-byte what `master` reports, with no warnings and no RSS fallbacks. - Tests cover the denied, exited, zombie, and missing-`/proc` cases, both PSS fallbacks and their warnings, the latch, and a vanished process not being misreported as a denial. *✍️ Drafted by Claude Code* --------- Co-authored-by: Vlada Dusek <v.dusek96@gmail.com>
A
Anas Khan committed
5ad4e53ba9bfbaa0147dd9535bfcadf0c89ce3ff
Parent: 4a4c8c1
Committed by GitHub <noreply@github.com>
on 7/29/2026, 6:30:01 AM