Skip to content

fix: memory & status info for Podman - #3802

Closed
sdargoeuves wants to merge 1 commit into
ipspace:nl-status-collectingfrom
sdargoeuves:podman_cli_status
Closed

fix: memory & status info for Podman#3802
sdargoeuves wants to merge 1 commit into
ipspace:nl-status-collectingfrom
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).

@sdargoeuves

Copy link
Copy Markdown
Collaborator Author

I'm in unchartered territory regarding git/github. I've submitted the PR against your branch nl-status-collecting instead of dev as from my perspective, those 2 PR are linked.
Now github is proposing to stack those PR, not sure if I should or not.
Let me know if it's just easier to create the PR against dev!

@ipspace
ipspace deleted the branch ipspace:nl-status-collecting August 21, 2026 08:51
@ipspace ipspace closed this Aug 21, 2026
@ipspace

ipspace commented Aug 21, 2026

Copy link
Copy Markdown
Owner

I'm in unchartered territory regarding git/github.

You're obviously not the only one lost :((

Let me know if it's just easier to create the PR against dev!

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.

@sdargoeuves

Copy link
Copy Markdown
Collaborator Author

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.
I'm not sure what is the correct process to submit a PR against an un-merged branch, with changes on the same file. It doesn't happen enough to be something I want to investigate yet.

Long story short, I'll create the new PR :)

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