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

Fix not reporting memory usage #66

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

spowelljr
Copy link
Contributor

@spowelljr spowelljr commented Jun 1, 2022

Fixes #64

When I was running crictl stats I wasn't getting any memory usage reported, everything was 0.

$ crictl stats
CONTAINER           CPU %               MEM                 DISK                INODES
151dfb4aa44a8       2.33                0B                  0B                  0
8396e703be70c       0.40                0B                  0B                  0
8d098a7107992       0.00                0B                  2.294kB             0
d1431067b2940       0.19                0B                  0B                  0
dbce1442651b2       6.69                0B                  0B                  0
f4c66fafc1f19       0.43                0B                  0B                  0
f8e33de11bb58       0.30                0B                  0B                  0
fe27b6c89bdb6       3.57                0B                  0B                  0

I checked the response of:

response, err := d.client.ContainerStats(ctx, id, false)

And it was:

{
   ...
   "memory_stats":{
      "usage":14479360,
      "stats":{...},
      "limit":6232580096
   },
   ...
}

There is no PrivateWorkingSet field being returned from Docker, changing it to Usage resulted in the following:

CONTAINER           CPU %               MEM                 DISK                INODES
219a899e5607d       0.31                11.55MB             0B                  0
24b4c111d2f5a       0.40                15.67MB             0B                  0
282e95aafc4b6       0.54                13.65MB             0B                  0
6751f1fd2b742       0.01                10.96MB             2.294kB             0
675fb173de807       2.75                43.97MB             0B                  0
8a3fa3d62f6e6       0.26                7.995MB             0B                  0
edc7e0037532c       7.35                345MB               0B                  0
ffadb0bd1808d       2.27                29.68MB             0B                  0

If you look at the source code of Docker you can see that Windows uses PrivateWorkingSet but Unix uses Usage.

Windows:
https://github.com/moby/moby/blob/548614694305d10e25665b4a7d0f61b025d47dd1/daemon/daemon_windows.go#L522

Unix:
https://github.com/moby/moby/blob/548614694305d10e25665b4a7d0f61b025d47dd1/daemon/daemon_unix.go#L1475

@evol262 evol262 merged commit 8536ae7 into Mirantis:master Jun 7, 2022
@spowelljr spowelljr deleted the fixMemoryOutput branch June 7, 2022 22:01
jandubois added a commit to lima-vm/alpine-lima that referenced this pull request Jun 8, 2022
Changes relevant for Lima are:

* Fix not reporting memory usage: Mirantis/cri-dockerd#66
* Make HairpinMode configurable: Mirantis/cri-dockerd#71

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
jandubois added a commit to rancher-sandbox/rancher-desktop-wsl-distro that referenced this pull request Jun 8, 2022
Changes relevant for Lima are:

* Fix not reporting memory usage: Mirantis/cri-dockerd#66
* Make HairpinMode configurable: Mirantis/cri-dockerd#71

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
evol262 added a commit that referenced this pull request Aug 5, 2022
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.

stats command failing to retrieve memory
2 participants