Skip to content

Fix: Podman cli status & memory - #3804

Merged
ipspace merged 1 commit into
ipspace:devfrom
sdargoeuves:podman_cli_status
Aug 21, 2026
Merged

Fix: Podman cli status & memory#3804
ipspace merged 1 commit into
ipspace:devfrom
sdargoeuves:podman_cli_status

Conversation

@sdargoeuves

Copy link
Copy Markdown
Collaborator

Fix netlab status --memory for Podman runtime

When using defaults.providers.clab.runtime: podman, the netlab status and
netlab status --memory commands showed no container status or memory usage.

Root cause

Podman's Docker-compatible CLI returns JSON differently from Docker:

Docker Podman
docker ps --format json one JSON object per line JSON array
Names field string list of strings
docker stats --format json one JSON object per line JSON array
field names Name, MemUsage name, mem_usage
memory units binary (KiB, MiB, GiB) decimal (kB, MB, GB)

Changes

providers/clab/__init__.py

  • get_lab_status: if docker ps output is a JSON array (Podman), normalize it
    to Docker's per-line format and unwrap Names from list to string before
    running the existing parsing logic unchanged.
  • add_memory_usage: same normalization for docker stats — map Podman's
    name/mem_usage fields to Docker's Name/MemUsage, then parse and
    re-format the value in binary units (MiB/GiB) so the memory column is
    consistent across Docker, Podman, and libvirt VMs.

utils/strings.py

  • MEMORY_UNITS: added decimal SI units (KB, MB, GB, TB) alongside
    the existing binary ones, with correct byte-to-KiB conversion factors.
  • parse_memory_size: extended the regex to also match decimal unit suffixes
    ([KMGT]B).

@ipspace ipspace left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and still works with Docker ;) Thank you!

@ipspace
ipspace merged commit 58c8e3f into ipspace:dev Aug 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants