Update module memory metric calculation based on dockerd recommendations #7480
+10
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original code calculated the used memory metric as
usage - cache. However, per 1, dockerd wants us to dousage - inactive_fileon cgroup v2 hosts andusage - total_inactive_fileon cgroup v1 hosts, becausecachewas deprecated after dockerd v19.03 . This is also what docker CLI does 2 vs what it used to in v19.03 and earlier 3.So we replicate the same behavior in EA, but we keep the fallback to
cachejust in case someone is running on an old dockerd, and we check the cgroup v2 field before the cgroup v1 field which is the opposite of what docker CLI does.Footnotes
https://docs.docker.com/reference/cli/docker/container/stats/ ↩
https://github.com/docker/cli/blob/965a0e3518c5740e9fe645ca19aa991b39fb1357/cli/command/container/stats_helpers.go#L239-L249 ↩
https://github.com/docker/cli/commit/a4a07c643042f4e2a75bf872f38b134502848214#diff-5daf453974f7b038c7e40119b1acd4cdd9a82dc878bc4b4c0925b29b2a1dd107 ↩