Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory Limit is returning invalid result for /container/stats REST API on macOS #15765

Closed
benoitf opened this issue Sep 13, 2022 · 2 comments · Fixed by #15811
Closed

memory Limit is returning invalid result for /container/stats REST API on macOS #15765

benoitf opened this issue Sep 13, 2022 · 2 comments · Fixed by #15811
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. podman-desktop

Comments

@benoitf
Copy link
Contributor

benoitf commented Sep 13, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

The field memory_stats.limit is returning an invalid value

Steps to reproduce the issue:

  1. Start a dummy container like fedora
$ MY_DUMMY_CONTAINER=$(podman run -d fedora sleep 20000)
  1. Display the memory of the container from inside the container
$ podman exec -ti $MY_DUMMY_CONTAINER cat /proc/meminfo | head -3
MemTotal:        2018452 kB
MemFree:          860084 kB
MemAvailable:    1556036 kB
  1. Now, read the value returned by the REST API
curl --silent --unix-socket /Users/benoitf/.local/share/containers/podman/machine/podman-machine-default/podman.sock "http:/v1.41/containers/$MY_DUMMY_CONTAINER/stats?stream=false&one-shot=true"  | jq .memory_stats
{
  "usage": 94208,
  "max_usage": 18446744073709552000,
  "limit": 18446744073709552000
}

Describe the results you received:

  "limit": 18446744073709552000

it seems this value is like the maximum value of the int/long/etc

Describe the results you expected:

something displaying around 2GB / 2Gi because it's the size of the machine.

  "limit": 2066894848

and based from
https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerStats

used_memory = memory_stats.usage - memory_stats.stats.cache
available_memory = memory_stats.limit
Memory usage % = (used_memory / available_memory) * 100.0

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

4.2.1

Output of podman info:

4.2.1

Package info (e.g. output of rpm -q podman or apt list podman):

(paste your output here)

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes/No

Additional environment details (AWS, VirtualBox, physical, etc.):

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 13, 2022
@vrothberg
Copy link
Member

Thanks for reaching out, @benoitf!

@giuseppe, can you take a look? This looks like a cgroup stats issue at first glance.

@giuseppe
Copy link
Member

Docker caps the value returned from the cgroup to the maximum available memory, so I guess we are forced to do the same thing for compatibility, opened a PR: #15811

giuseppe added a commit to giuseppe/libpod that referenced this issue Sep 15, 2022
Docker compatibility: cap the memory limit reported by the cgroup to
the maximum available memory.

Closes: containers#15765

Signed-off-by: Giuseppe Scrivano <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. podman-desktop
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants