fix: memory & status info for Podman - #3802
Conversation
|
I'm in unchartered territory regarding git/github. I've submitted the PR against your branch |
You're obviously not the only one lost :((
I merged the other PR and deleted the branch (as always), and all of a sudden, this one is an orphan :(( I'm sorry for the mess; please resubmit it. |
Don't worry it's all good, it was interesting to see what would happen! And it makes sense this PR became orphan as it was against a branch which no longer exists. Long story short, I'll create the new PR :) |
Fix
netlab status --memoryfor Podman runtimeWhen using
defaults.providers.clab.runtime: podman, thenetlab statusandnetlab status --memorycommands showed no container status or memory usage.Root cause
Podman's Docker-compatible CLI returns JSON differently from Docker:
docker ps --format jsonNamesfielddocker stats --format jsonName,MemUsagename,mem_usageKiB,MiB,GiB)kB,MB,GB)Changes
providers/clab/__init__.pyget_lab_status: ifdocker psoutput is a JSON array (Podman), normalize itto Docker's per-line format and unwrap
Namesfrom list to string beforerunning the existing parsing logic unchanged.
add_memory_usage: same normalization fordocker stats— map Podman'sname/mem_usagefields to Docker'sName/MemUsage, then parse andre-format the value in binary units (MiB/GiB) so the memory column is
consistent across Docker, Podman, and libvirt VMs.
utils/strings.pyMEMORY_UNITS: added decimal SI units (KB,MB,GB,TB) alongsidethe existing binary ones, with correct byte-to-KiB conversion factors.
parse_memory_size: extended the regex to also match decimal unit suffixes(
[KMGT]B).