Skip to content

Conversation

@gordonwang0
Copy link
Contributor

The original code calculated the used memory metric as usage - cache. However, per 1, dockerd wants us to do usage - inactive_file on cgroup v2 hosts and usage - total_inactive_file on cgroup v1 hosts, because cache was 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 cache just 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

  1. https://docs.docker.com/reference/cli/docker/container/stats/

  2. https://github.com/docker/cli/blob/965a0e3518c5740e9fe645ca19aa991b39fb1357/cli/command/container/stats_helpers.go#L239-L249

  3. https://github.com/docker/cli/commit/a4a07c643042f4e2a75bf872f38b134502848214#diff-5daf453974f7b038c7e40119b1acd4cdd9a82dc878bc4b4c0925b29b2a1dd107

…ons.

The original code calculated the used memory metric as `usage - cache`.
However, per [^1], dockerd wants us to do `usage - inactive_file` on cgroup v2
hosts and `usage - total_inactive_file` on cgroup v1 hosts, because `cache`
was 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 `cache`
just 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.

[^1]: https://docs.docker.com/reference/cli/docker/container/stats/

[^2]: https://github.com/docker/cli/blob/965a0e3518c5740e9fe645ca19aa991b39fb1357/cli/command/container/stats_helpers.go#L239-L249

[^3]: docker/cli@a4a07c6#diff-5daf453974f7b038c7e40119b1acd4cdd9a82dc878bc4b4c0925b29b2a1dd107
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.

3 participants