Handle container creation when cgroups have already been mounted in another location #1372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #1367, if a non-cpuset subsystem has been been mounted earlier in the mount table at a disjoint location to the rest of the hierarchy (e.g.
/sys/fs/cgroup/{cpuset,cpu,memory...}
) thenrunc create
will fail with:To replicate this behaviour, using Ubuntu 14.04 with a 4.4 kernel (linux-generic-lts-xenial package), create a mount table that looks like this:
Note that /cgroup can't have subsystem cpuset, otherwise everything will be fine.
On runc master:
Using this PR, creation completes successfully. It succeeds because we no longer use the "cgroup root" (the dir that is assumed to contain all cgroup subsystem mountpoints) to work out the highest cpuset subsystem dir. Instead we look for the closest mountpoint ancestor of the cgroup dir we are operating on.
The following shell functions may come in handy for setting up a mount table that looks like this:
We weren't sure how to integration test this, as providing a mount table like above seems to break the integration tests in docker, precisely due to this bug but if anyone has any ideas we are happy to update.
We think it would be ideal if runc took a "cgroup root" as configuration (it could be optional), but didn't want to change too much in this PR.
Cheers,
@williammartin and Craig