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 cgroupv2 mem usage calculation to match docker cli #3370

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

sparrc
Copy link
Contributor

@sparrc sparrc commented Aug 30, 2022

"cache" memory stat no longer exists in cgroupv2.

docker cli subtracts "inactive_file" for the overall mem usage
calculation, so do the same for cgroupv2.

closes #3323

for reference also see moby/moby#40727

Summary

Testing

Agent code was instrumented to log the exact mem usage that it is sending to cloudwatch. This was then manually compared to what docker cli outputs before and after this change.

Note in the logging below that the mem usage "AFTER" this change more accurately matches the docker cli value of 51.85 MiB

src/github.com/aws/amazon-ecs-agent % docker stats f6bf24ec4486 --no-stream
CONTAINER ID   NAME                                             CPU %     MEM USAGE / LIMIT   MEM %     NET I/O       BLOCK I/O     PIDS
f6bf24ec4486   ecs-tomcat-sample-4-main1-f4e2c581ecd7d49c9201   0.05%     51.85MiB / 256MiB   20.25%    1.14kB / 0B   0B / 2.03MB   30

src/github.com/aws/amazon-ecs-agent % tail -f /var/log/ecs/ecs-agent.log   
level=info time=2022-08-29T23:00:50Z msg="BEFORE: 51.8906 mb    AFTER: 51.8516" module=utils_unix.go
level=info time=2022-08-29T23:00:51Z msg="BEFORE: 51.8906 mb    AFTER: 51.8516" module=utils_unix.go

also see #3323

New tests cover the changes: no

Description for the changelog

Bugfix: Fix cgroupv2 mem usage calculation to match docker cli

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sparrc sparrc changed the title [wip] Fix cgroupv2 mem usage calculation to match docker cli Fix cgroupv2 mem usage calculation to match docker cli Aug 30, 2022
fierlion
fierlion previously approved these changes Aug 30, 2022
"cache" memory stat no longer exists in cgroupv2.

docker cli subtracts "inactive_file" for the overall mem usage
calculation, so do the same for cgroupv2.

closes aws#3323
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.

4 participants