Skip to content
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

support cgroup2 #3799

Merged
merged 2 commits into from
Dec 12, 2019
Merged

support cgroup2 #3799

merged 2 commits into from
Dec 12, 2019

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Nov 5, 2019

  • only shim v2 runc v2 ("io.containerd.runc.v2") is supported
  • only PID metrics is implemented. Others should be implemented in separate PRs.
  • lots of code duplication in v1 metrics and v2 metrics. Dedupe should be separate PR.
  • Tested with both runc and crun on git master

Signed-off-by: Akihiro Suda [email protected]

@AkihiroSuda AkihiroSuda mentioned this pull request Nov 5, 2019
11 tasks
@codecov-io
Copy link

codecov-io commented Nov 5, 2019

Codecov Report

Merging #3799 into master will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3799      +/-   ##
==========================================
- Coverage   42.33%   42.29%   -0.05%     
==========================================
  Files         130      130              
  Lines       14678    14688      +10     
==========================================
- Hits         6214     6212       -2     
- Misses       7539     7550      +11     
- Partials      925      926       +1
Flag Coverage Δ
#linux 45.7% <0%> (-0.06%) ⬇️
#windows 37.8% <ø> (ø) ⬆️
Impacted Files Coverage Δ
services/server/server_linux.go 0% <0%> (ø) ⬆️
snapshots/btrfs/btrfs.go 57.39% <0%> (-0.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f01665a...b02e20f. Read the comment docs.

@thaJeztah
Copy link
Member

@dmcgowan @crosbymichael @kolyshkin ptal

@crosbymichael
Copy link
Member

I know about it, its not ready yet from the cgroup lib POV

@AkihiroSuda
Copy link
Member Author

I will update PR when containerd/cgroups reach feature-complete for memory stats

@AkihiroSuda AkihiroSuda force-pushed the cgroup2 branch 4 times, most recently from f6d3fcd to 3bc6ad9 Compare November 16, 2019 08:54
@AkihiroSuda
Copy link
Member Author

Added PID metrics.

I intentionally omitted other metrics so that multiple contributors can work on them in parallel as we have done in containerd/cgroups#104. (Thanks @Zyqsempai and Michael)

How to test this PR

$ mkdir /sys/fs/cgroup/default
$ echo +pids > /sys/fs/cgroup/default/cgroup.subtree_control
$ ctr run -t --runc-binary crun --rm docker.io/library/alpine:latest foo
$ ctr t metrics foo
ID     TIMESTAMP                                  
foo    2019-11-16 08:53:45.740847757 +0000 UTC    

METRIC          VALUE                   
pids.current    1                       
pids.limit      18446744073709551615
  • Currently subtree_control needs to be toggled outside containerd. We may want to change this behavior later.
  • --runc-binary crun is not necessary but recommended until runc gets matured.

@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@containerd containerd deleted a comment from theopenlab-ci bot Nov 16, 2019
@Zyqsempai
Copy link
Contributor

@AkihiroSuda Can you please create todo list as well, for better control of what and when should be done, I would love to work here as well.

@AkihiroSuda
Copy link
Member Author

checklist: #3726

@Zyqsempai
Copy link
Contributor

Shall we merge it? to continue working on other metrics!

@crosbymichael
Copy link
Member

Let me test this on my setup

@crosbymichael
Copy link
Member

Do you know the kernel configs that I need for the ebpf devices?

Trying this out I get:

ctr: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"process_linux.go:415: setting cgroup config for procHooks process caused \\\"failed to load program: function not implemented\\\"\"": unknown

@crosbymichael
Copy link
Member

I dont' like how the stats are handled. We should output the prometheus metrics without any changes. People shouldn't have to have all new metric keys because we start using cgroups v2. We need to make the v2 code to the existing stats structs within containerd

@crosbymichael
Copy link
Member

I just tested this and got containers running under v2 with runc. It's looking good on the runtime side, we just need to map the stats structures so that this isn't a huge burden for users. We also need to figureout what we want to do with the subtree control file whenever we create a directory for a namespace.

@AkihiroSuda
Copy link
Member Author

Do you know the kernel configs that I need for the ebpf devices?

kernel >= 4.15 with CONFIG_CGROUP_DEVICE and CONFIG_CGROUP_BPF is required.
I'm using kernel 5.3 shipped with Ubuntu 19.10.

@crosbymichael
Copy link
Member

I got it to work. you need a couple others like BPF_syscall

@AkihiroSuda
Copy link
Member Author

If separating stat structs are problematic for downstream projects, maybe we can have some translator library in contrib directory to help them.

@theopenlab-ci

This comment has been minimized.

@AkihiroSuda
Copy link
Member Author

also added commit for enabling controllers automatically

@theopenlab-ci

This comment has been minimized.

@theopenlab-ci

This comment has been minimized.

@fuweid
Copy link
Member

fuweid commented Dec 7, 2019

need to rebase 😂

@AkihiroSuda
Copy link
Member Author

rebased

@theopenlab-ci

This comment has been minimized.

@theopenlab-ci

This comment has been minimized.

* only shim v2 runc v2 ("io.containerd.runc.v2") is supported
* only PID metrics is implemented. Others should be implemented in separate PRs.
* lots of code duplication in v1 metrics and v2 metrics. Dedupe should be separate PR.

Signed-off-by: Akihiro Suda <[email protected]>
@theopenlab-ci
Copy link

theopenlab-ci bot commented Dec 11, 2019

Build succeeded.

Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @AkihiroSuda


var pidMetrics = []*metric{
{
name: "pids_v2",
Copy link
Member

Choose a reason for hiding this comment

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

i feel like this shouldn't be needed, changing the metric name as the values are the same between v1 and v2. This can be updated after and I think this PR is good to be merged now.

@crosbymichael
Copy link
Member

LGTM

@crosbymichael crosbymichael merged commit 5d93ece into containerd:master Dec 12, 2019
AkihiroSuda added a commit to AkihiroSuda/docker that referenced this pull request Dec 31, 2019
* Requires containerd binaries from containerd/containerd#3799 . Metrics are unimplemented yet.
* Works with crun v0.10.4, but `--security-opt seccomp=unconfined` is needed unless using master version of libseccomp
  ( containers/crun#156, seccomp/libseccomp#177 )
* Doesn't work with master runc yet
* Resource limitations are unimplemented

Signed-off-by: Akihiro Suda <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Jan 9, 2020
* Requires containerd binaries from containerd/containerd#3799 . Metrics are unimplemented yet.
* Works with crun v0.10.4, but `--security-opt seccomp=unconfined` is needed unless using master version of libseccomp
  ( containers/crun#156, seccomp/libseccomp#177 )
* Doesn't work with master runc yet
* Resource limitations are unimplemented

Signed-off-by: Akihiro Suda <[email protected]>
Upstream-commit: 612343618dd7dad7cf023e6263d693ab37507a92
Component: engine
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.

7 participants