Skip to content

cgroup2: implement docker stats#40657

Merged
AkihiroSuda merged 1 commit into
moby:masterfrom
AkihiroSuda:cgroup2-stats
Apr 2, 2020
Merged

cgroup2: implement docker stats#40657
AkihiroSuda merged 1 commit into
moby:masterfrom
AkihiroSuda:cgroup2-stats

Conversation

@AkihiroSuda

@AkihiroSuda AkihiroSuda commented Mar 9, 2020

Copy link
Copy Markdown
Member

- What I did

Implemented docker stats for cgroup2.

The following fields are unsupported (not used by docker CLI):

  • BlkioStats: all fields other than IoServiceBytesRecursive
  • CPUStats: CPUUsage.PercpuUsage
  • MemoryStats: MaxUsage and Failcnt

- How I did it

See the code.

- How to verify it

$ docker run -d --name foo --cpus 0.5 --memory 32m --runtime crun alpine \
  sh -exc "apk add --no-cache stress-ng && stress-ng --cpu 0"
f3085a21a2e2f0aa1e6d3fc8682aa47f233c561d9f8aced9fd2dfd6297f742e3

$ docker stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
afaae62989ba        foo                 49.92%              13.19MiB / 32MiB    41.22%              4.07MB / 42.7kB     0B / 3.48MB         3

Tested on Ubuntu 19.10, containerd/containerd@936b7b0, crun v0.13.

- Description for the changelog

cgroup2: implement docker stats

- A picture of a cute animal (not mandatory but encouraged)
🐧

@AkihiroSuda

AkihiroSuda commented Mar 9, 2020

Copy link
Copy Markdown
Member Author

@Zyqsempai Are you interested in filling up missing containerd/cgroups fields?

EDIT: What we can add now seems only FailCnt, and this is not urgent (not used by docker CLI)

@Zyqsempai

Copy link
Copy Markdown

@AkihiroSuda Yes I am, thanks!

@AkihiroSuda
AkihiroSuda force-pushed the cgroup2-stats branch 2 times, most recently from 5d5fd69 to 570d706 Compare March 10, 2020 09:11
@AkihiroSuda

Copy link
Copy Markdown
Member Author

Added blkio stats. Should be ready to review and merge.

@AkihiroSuda AkihiroSuda added this to the 20.03.0 milestone Mar 10, 2020
Comment thread libcontainerd/types/types_linux.go Outdated

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AkihiroSuda

Copy link
Copy Markdown
Member Author

@thaJeztah PTAL?

@AkihiroSuda

Copy link
Copy Markdown
Member Author

@kolyshkin PTAL?

@kolyshkin kolyshkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@AkihiroSuda

Copy link
Copy Markdown
Member Author

Can we merge this?

@thaJeztah

Copy link
Copy Markdown
Member

IIUC, some information will be different / not present depending on if V1 or V2 is used? If so, perhaps we should add a note to the swagger docs to mention this?

I'm ok if that's done in a follow-up

The following fields are unsupported:

* BlkioStats: all fields other than IoServiceBytesRecursive
* CPUStats: CPUUsage.PercpuUsage
* MemoryStats: MaxUsage and Failcnt

Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda

Copy link
Copy Markdown
Member Author

added swagger doc

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@AkihiroSuda
AkihiroSuda merged commit 4a67e7b into moby:master Apr 2, 2020
@AkihiroSuda AkihiroSuda added the area/cgroup2 cgroup v2 label Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants