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

kubelet: add initial support for cgroupv2 #85218

Merged
merged 1 commit into from Mar 26, 2020

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Nov 13, 2019

/kind feature

do a conversion from the cgroups v1 limits to cgroups v2.

e.g. cpu.shares on cgroups v1 has a range of [2-262144] while the
equivalent on cgroups v2 is cpu.weight that uses a range [1-10000].

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

Does this PR introduce a user-facing change?:

NONE

Support for running on a host that uses cgroups v2 unified mode

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 13, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @giuseppe. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 13, 2019
Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

/uncc

Looking forward to reading the KEP :) Removing myself as a reviewer while this diff is WIP.

@mrunalp
Copy link
Contributor

mrunalp commented Nov 14, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 14, 2019
@giuseppe
Copy link
Member Author

Looking forward to reading the KEP :) Removing myself as a reviewer while this diff is WIP.

KEP here: kubernetes/enhancements#1370

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2020
@derekwaynecarr
Copy link
Member

/assign

Copy link
Member

@derekwaynecarr derekwaynecarr left a comment

Choose a reason for hiding this comment

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

i want to review this a little closer.

no conversion was needed for pids and hugepages, correct?

Cgroups: cgroups,
Paths: paths,
}, nil
f, err := cgroupsystemd.NewSystemdCgroupsManager()
Copy link
Member

Choose a reason for hiding this comment

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

does this manager work on v1 and v2 hosts?

Copy link
Member

Choose a reason for hiding this comment

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

i need to check the runc code, but is this abstracing legacy from unified manager?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, NewSystemdCgroupsManager() checks for the cgroup version used:

https://github.com/opencontainers/runc/blob/master/libcontainer/cgroups/systemd/apply_systemd.go#L118-L136

If we are running on cgroup v1, it will use cgroupsystemd.LegacyManager

Copy link
Member

Choose a reason for hiding this comment

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

thanks for pointer, and noting that i confirmed this is in the vendored version.

@giuseppe
Copy link
Member Author

no conversion was needed for pids and hugepages, correct?

yes correct, both pids and hugetlb don't need any conversion. I'll need to add support for hugetlb to cAdvisor though, once Linux 5.6 is out (it is still at 5.6-rc5), support in libcontainer is already being added.

@mattjmcnaughton
Copy link
Contributor

Cool stuff!
It will take me a couple of days to give this a full review (gotta read up on cgroup v2 a bit first :) ).

@giuseppe I haven't forgotten about this :) I just haven't had a lot of time to review larger PRs recently :) Will hopefully have thoughts by end of week. Thanks for your patience.

/uncc

Whoops, I didn't get to this before @derekwaynecarr did. Tbh, I don't see myself adding anything that his review wouldn't, so going to defer to him on the review :)

if libcontainercgroups.IsCgroup2UnifiedMode() {
if resourceConfig.CpuShares != nil {
// Convert from the range [2-262144] to [1-10000]
resources.CpuWeight = (1 + ((*resourceConfig.CpuShares-2)*9999)/262142)
Copy link
Member

Choose a reason for hiding this comment

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

minor nit: may be useful to move this conversion into a helper that we can then unit test in a follow-on.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR here: #89567

Copy link
Member

@derekwaynecarr derekwaynecarr left a comment

Choose a reason for hiding this comment

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

great to see this progress.

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 26, 2020
@derekwaynecarr
Copy link
Member

/milestone v1.19

@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Mar 26, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: derekwaynecarr, giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2020
@k8s-ci-robot k8s-ci-robot merged commit 34c8b26 into kubernetes:master Mar 26, 2020
@mattjmcnaughton
Copy link
Contributor

Wow, exciting stuff @giuseppe @derekwaynecarr - big thank you for all your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants