-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
calculateMemUsageUnixNoCache: subtract total_inactive_file, not cache #2415
Conversation
15c3d1c
to
f6ef10b
Compare
4e0b583
to
e4ac9b1
Compare
CI failure is unrelated: #2412 |
Previous change related to was #80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
but pinging @cpuguy83 @crosbymichael @tiborvass for review as well
func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 { | ||
return float64(mem.Usage - mem.Stats["cache"]) | ||
// cgroup v1 | ||
if v, isCgroup1 := mem.Stats["total_inactive_file"]; isCgroup1 && v < mem.Usage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we use this information elsewhere (in the daemon) as well? Just making sure that there's no logic somewhere using the old calculation.
Also /cc @SamWhited (I think UCP does some similar calculations for the UI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the daemon AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm not too worried about the CLI reporting slightly different numbers as long as the formula for the calculation is accurate and documented.
@AkihiroSuda can you rebase to make CI go green? I'll merge after that |
The new stat definition corresponds to containerd/CRI and cadvisor. https://github.com/containerd/cri/blob/c1115d4e57f55a5f45fb3efd29d3181ce26d5c6a/pkg/server/container_stats_list_unix.go#L106-L129 google/cadvisor@307d1b1 Fix moby/moby#40727 Signed-off-by: Akihiro Suda <[email protected]>
e4ac9b1
to
a4a07c6
Compare
rebased |
thanks! all green - merging |
Docker 20.10 changed the way how memory usage of docker containers is calculated, the docker check was adapted accordingly. See docker/cli#2415 for more information. CMK-5224 Change-Id: Ib6c6aa21f61f5cd750209dc3b3bda82041f9d49c
- What I did
Changed
mem.Usage - mem.Stats["cache"]
incalculateMemUsageUnixNoCache()
used bydocker stats
CLI tomem.Usage - mem.Stats["total_inactive_file"]
.Fix moby/moby#40727
- How I did it
The new stat definition corresponds to containerd/CRI and cadvisor.
https://github.com/containerd/cri/blob/c1115d4e57f55a5f45fb3efd29d3181ce26d5c6a/pkg/server/container_stats_list_unix.go#L106-L129
google/cadvisor@307d1b1
- How to verify it
See moby/moby#40727
- Description for the changelog
Changed
mem.Usage - mem.Stats["cache"]
incalculateMemUsageUnixNoCache()
used bydocker stats
CLI tomem.Usage - mem.Stats["total_inactive_file"]
.- A picture of a cute animal (not mandatory but encouraged)
🐧