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

systemd cgroup driver supports slice management #1084

Merged
merged 1 commit into from
Oct 7, 2016

Conversation

derekwaynecarr
Copy link
Contributor

@derekwaynecarr derekwaynecarr commented Sep 27, 2016

This patch adds support for the systemd cgroup driver to manage slices.

The ability to manage slices via the dbus api was not available until systemd v229, but some distros have back-ported it to earlier levels. The driver verifies the ability to start a slice via a transient unit is supported prior to using the feature.

If the supplied cgroup name ends with a .slice suffix, we assume the user wanted a slice created instead of a scope. Creation of a slice does not require a PID, so support from the cgroupfs driver for pid=-1 is carried over into systemd driver.

Finally, ExpandSlice is made public for use by downstream consumers. In addition, it fixes a logic error associated with -.slice needing to be / when expanded.

Signed-off-by: derekwaynecarr [email protected]

@derekwaynecarr
Copy link
Contributor Author

/cc @vishh @mrunalp @dubstack

@derekwaynecarr
Copy link
Contributor Author

/cc @euank

Copy link
Contributor

@vishh vishh left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Just a couple of comments.

@@ -159,8 +160,36 @@ func UseSystemd() bool {
}
}

// Assume we have the ability to start a transient unit as a slice
// This was broken until systemd v229, but has been back-ported on RHEL environments >= 219
// For details, see: https://bugzilla.redhat.com/show_bug.cgi?id=1370299
Copy link
Contributor

Choose a reason for hiding this comment

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

Any details on other distros?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would strongly suspect that other distros will not work with systemd <= 229, we can verify the other distros when we consume this in kubernetes. i doubt others have patched their systemd.

Copy link
Member

Choose a reason for hiding this comment

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

Can I just clarify here what you mean by "broken"? Do you mean that the interface didn't exist / always returned an error? Or do you mean that there was some issues with how systemd treated such slices (in which case, is the code you've added sufficient to protect against that)? I'm just asking because we've had some horrible issues with systemd's DBus interface and I generally don't trust that project to handle things sanely anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyphar - by broken, I mean you would literally get an error back from systemd when you called start transient unit where the unit was a .slice.

The error response had the text: Unit type slice does not support transient units.

This was fixed in systemd/systemd@17f62e9

As part of systemd/systemd#1886

The code addresses this by:

  1. attempting to start a slice, and if successful, it sets hasStartTransientUnitSlice to true.
  2. if it detects you cannot, and you later attempt to start a transient unit of type slice, it will error early with the message that your systemd level did not support the feature yet.

Does that help?

Copy link
Member

Choose a reason for hiding this comment

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

Alright, in that case I'm okay with this.

// For details, see: https://bugzilla.redhat.com/show_bug.cgi?id=1370299
hasStartTransientSliceUnit = true

// To ensure simple clean-up, we create a slice off the root with no hierarchy
Copy link
Contributor

Choose a reason for hiding this comment

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

What if runc were to be running underneath a container? Is that a supported use-case @crosbymichael ?

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 follows the same convention as the scope check, so i think it should be fine...

Copy link
Member

Choose a reason for hiding this comment

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

runC inside a container is a supported config, however in general you aren't running systemd inside that container (so this is a moot point). Though, some people work on running systemd inside containers and might have issues with this. But since it would've been broken before I'm not worried about breaking it twice.

@derekwaynecarr
Copy link
Contributor Author

poke @mrunalp

@mrunalp
Copy link
Contributor

mrunalp commented Oct 5, 2016

LGTM

Approved with PullApprove

@cyphar
Copy link
Member

cyphar commented Oct 6, 2016

I'm holding off LGTM-ing this until I can better understand what you mean by "broken". I've also kicked off the CI (it looks like GitHub missed the hook).

@cyphar
Copy link
Member

cyphar commented Oct 7, 2016

LGTM. Merging.

Approved with PullApprove

@cyphar cyphar merged commit 1a75f81 into opencontainers:master Oct 7, 2016
cyphar added a commit that referenced this pull request Oct 7, 2016
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.

4 participants