From 42ac777ed3a67597b7e4932deb5dc539035b0a76 Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Tue, 14 Mar 2017 16:09:09 -0400 Subject: [PATCH] Add mount point to cgroup root when initializing cgroup paths for cpu.rt_runtime PR https://github.com/docker/docker/pull/23430 introduced a couple more flags including `--cpu-rt-runtime` to the docker daemon. It appears recent changes or merge issues may have broken this. It currently does not take the cgroup mount point into account when determining the cgroup files to write values to. This breaks docker setting its own `cpu.rt_runtime` for the daemon. This also means containers aren't able to set theirs. Also, the cgroups.FindCgroupMountpointAndRoot returns back a mount point that includes the cgroup of the currently running container when docker is run inside a docker container. this breaks the `--cpu-rt-runtime` flag when running docker in docker. A fix has been placed here, but potentially could be pulled up into libcontainer if this is a better place for it. Signed-off-by: Erik St. Martin Upstream-commit: 40e075532ab4d01b4ceb36f145b95e2d3a5d951f Component: engine --- components/engine/daemon/daemon_unix.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/engine/daemon/daemon_unix.go b/components/engine/daemon/daemon_unix.go index 6a961bae01..88be482bde 100644 --- a/components/engine/daemon/daemon_unix.go +++ b/components/engine/daemon/daemon_unix.go @@ -1269,12 +1269,17 @@ func (daemon *Daemon) initCgroupsPath(path string) error { // for the period and runtime as this limits what the children can be set to. daemon.initCgroupsPath(filepath.Dir(path)) - _, root, err := cgroups.FindCgroupMountpointAndRoot("cpu") + mnt, root, err := cgroups.FindCgroupMountpointAndRoot("cpu") if err != nil { return err } + // When docker is run inside docker, the root is based of the host cgroup. + // Should this be handled in runc/libcontainer/cgroups ? + if strings.HasPrefix(root, "/docker/") { + root = "/" + } - path = filepath.Join(root, path) + path = filepath.Join(mnt, root, path) sysinfo := sysinfo.New(true) if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimePeriod, daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil { return err