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

Add support for enabling systemd cgroups #667

Merged
merged 3 commits into from Mar 23, 2016

Conversation

mrunalp
Copy link
Contributor

@mrunalp mrunalp commented Mar 21, 2016

This adds a flag to enable systemd cgroups in runc.

Signed-off-by: Mrunal Patel mrunalp@gmail.com

@mrunalp
Copy link
Contributor Author

mrunalp commented Mar 21, 2016

@icecrime @crosbymichael @LK4D4 PTAL. This PR adds support to enable systemd cgroups for runc.

@icecrime
Copy link

Thanks! Cc @anusha-ragunathan @mlaventure.

@cyphar
Copy link
Member

cyphar commented Mar 22, 2016

/me is slightly cautious, given how many issues we've had with systemd in the past. At least it's no longer automatic, though.

@hqhq
Copy link
Contributor

hqhq commented Mar 22, 2016

LGTM

} else {
// Parse the path from expected "slice:prefix:name"
// for e.g. "system.slice:docker:1234"
parts := strings.Split(myCgroupPath, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not how docker works today. Refer daemon/oci_linux.go:createSpec. Couple of issues:

  1. CgroupParent and containerID are combined using a filepath.Join. Not by a colon separator.
  2. There's no ScopePrefix appended to the CgroupsPath.

Are the requirements about cgroups path being in "slice:prefix:name" format part of the spec? If yes, we will need docker changes to go along with this commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anusha-ragunathan Yes, I am well aware of that. The choice to encode the parameters within cgroupsPath was deliberate. The reason is that systemd cgroups API doesn't work with full cgroups paths. See https://github.com/opencontainers/runc/blob/master/libcontainer/cgroups/systemd/apply_systemd.go#L227

It expects the unit name that is formed from the prefix and name and the parent slice name.
Since OCI doesn't support these as first class fields, these are encoded in the cgroupsPath using ":" as a separator as a practical choice.

Also, I don't think that these should be first class concepts in OCI and runc can add this to support systemd cgroups as it isn't bound to just supporting OCI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to how docker supported systemd cgroups earlier using a daemon option. When the native.cgroupdriver is set to systemd, then createSpec could special form cgroupsPath using separators.

@anusha-ragunathan
Copy link
Contributor

LGTM

// for e.g. "system.slice:docker:1234"
parts := strings.Split(myCgroupPath, ":")
if len(parts) != 3 {
return nil, fmt.Errorf("expected cgroupsPath to be of format \"slice:prefix:name\" for systemd cgroups")
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add this to the help text ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated help text and the man page.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
@mrunalp
Copy link
Contributor Author

mrunalp commented Mar 23, 2016

@crosbymichael @LK4D4 ping

@crosbymichael
Copy link
Member

LGTM

@crosbymichael crosbymichael merged commit 2495096 into opencontainers:master Mar 23, 2016
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.

None yet

8 participants