Fix I/O stats showing 0/0 on cgroup v2 hosts - #375
Open
void143 wants to merge 1 commit into
Open
Conversation
The Docker stats API reports the blkio operation as "Read"/"Write" under cgroup v1 but lowercase "read"/"write" under cgroup v2. ReadIO compared the op with a case-sensitive equality, so on cgroup v2 hosts neither branch matched and every container reported 0/0 for IO read/write. Compare the op case-insensitively with strings.EqualFold so the values are populated correctly on both cgroup v1 and v2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
On cgroup v2 hosts, every container's IO column shows
0 / 0regardless of actual disk activity, whiledocker statsreports correct Block I/O for the same containers.Cause
The Docker stats API reports the blkio operation name differently between cgroup versions:
"Read"/"Write"(capitalized)"read"/"write"(lowercase)ReadIOinconnector/collector/docker.gocomparedblk.Opwith case-sensitive equality (== "Read"/== "Write"), so on cgroup v2 neither branch ever matches and the read/write totals stay at zero.Raw API sample from a cgroup v2 host (
io_service_bytes_recursive):{ "major": 259, "minor": 0, "op": "read", "value": 4096 } { "major": 259, "minor": 0, "op": "write", "value": 1781760 }Fix
Compare the operation case-insensitively with
strings.EqualFold, so the values populate correctly on both cgroup v1 and v2. No behavior change on cgroup v1.Testing
Verified on a Docker 27.5.1 host with cgroup v2 (systemd driver). After the change, ctop's IO read/write match
docker statsBlock I/O for the same containers.