Просмотр исходного кода

Merge pull request #42342 from AkihiroSuda/dind-fix-cgroup2-evac-2010

[20.10 backport] hack/dind: fix cgroup v2 evacuation with `docker run --init`
Tianon Gravi 4 лет назад
Родитель
Сommit
114310d76a
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      hack/dind

+ 3 - 2
hack/dind

@@ -27,10 +27,11 @@ fi
 
 # cgroup v2: enable nesting
 if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
-	# move the init process (PID 1) from the root group to the /init group,
+	# move the processes from the root group to the /init group,
 	# otherwise writing subtree_control fails with EBUSY.
+	# An error during moving non-existent process (i.e., "cat") is ignored.
 	mkdir -p /sys/fs/cgroup/init
-	echo 1 > /sys/fs/cgroup/init/cgroup.procs
+	xargs -rn1 < /sys/fs/cgroup/cgroup.procs > /sys/fs/cgroup/init/cgroup.procs || :
 	# enable controllers
 	sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers \
 		> /sys/fs/cgroup/cgroup.subtree_control