Browse code

Work around an exotic bug affecting Docker-in-Docker + systemd.

Jérôme Petazzoni authored on 2013/10/18 12:32:23
Showing 1 changed files
... ...
@@ -27,6 +27,31 @@ do
27 27
 	[ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS
28 28
 	mountpoint -q $CGROUP/$SUBSYS || 
29 29
 		mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS
30
+
31
+	# The two following sections address a bug which manifests itself
32
+	# by a cryptic "lxc-start: no ns_cgroup option specified" when
33
+	# trying to start containers withina container.
34
+	# The bug seems to appear when the cgroup hierarchies are not
35
+	# mounted on the exact same directories in the host, and in the
36
+	# container.
37
+
38
+	# Named, control-less cgroups are mounted with "-o name=foo"
39
+	# (and appear as such under /proc/<pid>/cgroup) but are usually
40
+	# mounted on a directory named "foo" (without the "name=" prefix).
41
+	# Systemd and OpenRC (and possibly others) both create such a
42
+	# cgroup. To avoid the aforementioned bug, we symlink "foo" to
43
+	# "name=foo". This shouldn't have any adverse effect.
44
+	echo $SUBSYS | grep -q ^name= && {
45
+		NAME=$(echo $SUBSYS | sed s/^name=//)
46
+		ln -s $SUBSYS $CGROUP/$NAME
47
+	}
48
+
49
+	# Likewise, on at least one system, it has been reported that
50
+	# systemd would mount the CPU and CPU accounting controllers
51
+	# (respectively "cpu" and "cpuacct") with "-o cpuacct,cpu"
52
+	# but on a directory called "cpu,cpuacct" (note the inversion
53
+	# in the order of the groups). This tries to work around it.
54
+	[ $SUBSYS = cpuacct,cpu ] && ln -s $SUBSYS $CGROUP/cpu,cpuacct
30 55
 done
31 56
 
32 57
 # Note: as I write those lines, the LXC userland tools cannot setup