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

Handle container creation when cgroups have already been mounted in another location #1372

Merged

Conversation

craigfurman
Copy link

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...}) then runc create will fail with:

container_linux.go:259: starting container process caused "process_linux.go:283: applying cgroup configuration for process caused \"open /sys/fs/cpuset.cpus: no such file or directory\""

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:

cgroup /cgroup cgroup rw,relatime,cpu 0 0
none /sys/fs/cgroup tmpfs rw,relatime 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/cpu cgroup rw,relatime,cpu 0 0
cgroup /sys/fs/cgroup/cpuacct cgroup rw,relatime,cpuacct 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,relatime,blkio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,relatime,memory 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,relatime,devices 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,relatime,freezer 0 0
cgroup /sys/fs/cgroup/net_cls cgroup rw,relatime,net_cls 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/net_prio cgroup rw,relatime,net_prio 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,relatime,pids 0 0

Note that /cgroup can't have subsystem cpuset, otherwise everything will be fine.

On runc master:

→ runc create test
container_linux.go:259: starting container process caused "process_linux.go:283: applying cgroup configuration for process caused \"open /sys/fs/cpuset.cpus: no such file or directory\""

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:

function cmount() { mount -t cgroup -o cpu cgroup /cgroup && mount -t tmpfs none /sys/fs/cgroup && cgroups-mount; }

function cumount { cgroups-umount && umount /sys/fs/cgroup && umount /cgroup; }

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

Runc needs to copy certain files from the top of the cgroup cpuset hierarchy
into the container's cpuset cgroup directory. Currently, runc determines
which directory is the top of the hierarchy by using the parent dir of
the first entry in /proc/self/mountinfo of type cgroup.

This creates problems when cgroup subsystems are mounted arbitrarily in
different dirs on the host.

Now, we use the most deeply nested mountpoint that contains the
container's cpuset cgroup directory.

Signed-off-by: Konstantinos Karampogias <[email protected]>
Signed-off-by: Will Martin <[email protected]>
@rh-atomic-bot
Copy link

257/265 passed on RHEL - Failed.
254/263 passed on CentOS - Failed.
263/264 passed on Fedora - Failed.
Log - https://aos-ci.s3.amazonaws.com/opencontainers/runc/runc-integration-tests-prs/294/fullresults.xml

@williammartin
Copy link

williammartin commented Mar 15, 2017

That failed Travis test looks to be a flake since I've seen on other Travis builds. I tried the !rebuild runc#1372 but didn't look like I was allowed.

Can someone kick the tests off again?

@cyphar
Copy link
Member

cyphar commented Mar 19, 2017

Wait, is the only cgroup that we have problems with cpuset? That doesn't sound right.

@craigfurman
Copy link
Author

@craigfurman
Copy link
Author

Hi @cyphar , I know you're busy, but did you get a chance to check out the explanation above?

@cyphar
Copy link
Member

cyphar commented May 16, 2017

LGTM. Sorry for the delay.

Approved with PullApprove

@williammartin
Copy link

No problem. Hmm, need one more LGTM on this, any idea who would be good to review?

@crosbymichael
Copy link
Member

crosbymichael commented May 25, 2017

LGTM

Approved with PullApprove

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.

5 participants