diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index 292b52c6..4feeb626 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -239,6 +239,13 @@ runner의 Docker proxy가 안쪽 dind daemon에 컨테이너를 띄운다. release 단계 provider job은 아직 job 컨테이너에서 돈다. - runner가 privileged 컨테이너를 막는 설정(rootless dind 등)으로 바뀌면 이 길이 깨진다. 그때는 위 조건을 갖춘 전용 runner(VM 등)로 옮긴다. +- 컨테이너의 첫 프로세스는 systemd를 띄우기 전에 root cgroup의 프로세스를 + `init.scope`로 옮기고 root에 cgroup 제어기를 켠다. 그러지 않으면 부팅 중에 + 닿은 `docker exec`가 root cgroup에 들어가 systemd가 제어기를 넘기지 못하고, + provider scope에 `memory.max`가 없어 아래 확인이 provider를 exit 125로 + 멈춘다(2026-11-14 desktop 4회 중 1회). `test:system`의 사전 점검 + (`scripts/check-system-test-prerequisites.ts`)이 user manager에 cpu·memory·pids + 제어기가 넘어왔는지 보고, 없으면 빠진 이름을 대며 실패한다. 각 provider는 고유한 collected user scope에서 실행된다. Supervisor는 실행 전에 실제 cgroup membership과 `memory.max=1073741824`, `memory.swap.max=0`, diff --git a/scripts/run-in-system-container.sh b/scripts/run-in-system-container.sh index 7ba7bfb5..0db07ac1 100755 --- a/scripts/run-in-system-container.sh +++ b/scripts/run-in-system-container.sh @@ -42,9 +42,32 @@ if ! $docker image inspect "$tag" > /dev/null 2>&1; then say "building $tag" $docker build -q -t "$tag" -f "$dockerfile" config/ci > /dev/null || fail "image build failed" fi -cid=$($docker run -d --privileged --cgroupns=private --tmpfs /run --tmpfs /run/lock "$tag") \ +# systemd hands the cgroup controllers the provider scope needs (cpu, memory, pids) down from the container's +# root cgroup. A `docker exec` that arrives while systemd starts, before it has enabled controllers there, +# joins that root cgroup, and while any process sits in it the kernel refuses to enable controllers on it +# (cgroup v2: a cgroup that hands controllers to children holds no processes). systemd then delegates +# nothing, every later exec joins the root cgroup too, and each provider scope lacks memory.max, so the +# provider cgroup gate exits 125 (1 run in 4 on desktop, 2026-11-14). So the container's first process +# moves every process out of the root cgroup and enables its controllers before it execs systemd, as +# moby's hack/dind does. From then on an exec cannot join the root cgroup and lands in PID 1's. +boot='cg=/sys/fs/cgroup +controllers=$(cat $cg/cgroup.controllers 2> /dev/null) || controllers= +if [ -n "$controllers" ]; then + mkdir -p $cg/init.scope + enable=$(printf "+%s " $controllers) + tries=0 + until { xargs -rn1 < $cg/cgroup.procs > $cg/init.scope/cgroup.procs; echo "$enable" > $cg/cgroup.subtree_control; } 2> /dev/null; do + tries=$((tries + 1)) + [ $tries -lt 50 ] || { echo "system-container: cannot enable the root cgroup controllers" >&2; break; } + sleep 0.1 + done +fi +exec /sbin/init' +cid=$($docker run -d --privileged --cgroupns=private --tmpfs /run --tmpfs /run/lock "$tag" /bin/sh -c "$boot") \ || fail "container did not start" cleanup() { + # The boot step writes to the container log only when it gave up; say so whatever ends the run. + $docker logs "$cid" 2>&1 | grep '^system-container:' >&2 || : if [ "${SYSTEM_CONTAINER_KEEP:-0}" = 1 ]; then say "kept container $cid"; else $docker rm -f "$cid" > /dev/null 2>&1 || :; fi } trap cleanup EXIT