Repository navigation
ci(runner): run.sh --cgroup-parent puts the CI containers under a cgroup of the host's choosing - #4061
Conversation
…er a cgroup of the host's choosing So a host can give its CI containers a low CPU weight (a system slice under a top-level slice with CPUWeight=20): the jobs run at full speed while the CPU is free and yield to the PC's own sessions when both want it, instead of being held back by a low runner count. A parent docker cannot use is refused at start, like a CPU list.
…t recipe needs cgroup v2
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Reviewed by the merge pass (the self-hosted runner launcher, a sensitive area: its own two reviews, a fresh omo reviewer and Codex, at this head). The Codex raised two points as mediums that the merge pass rules low: the launcher leaves the slice syntax to docker's own check (the probe runs it before anything starts, so a bad name fails closed), and an explicitly empty value is refused at start-up instead of meaning "none" (it fails loudly before any runner starts; an operator who wants none leaves the option out). Other low notes: the tests would not notice an unquoted value (their values have no spaces); with |
…d from shell and PowerShell files (#4115) ## What The restore PRs #4081, #4083 and #4087 put back the notes the comment pass dropped but should have kept (security notes, traps that name what breaks, platform facts, measured values). They held back eight shell and PowerShell files, because the refactor kit's comments-only proof cannot prove them (see "Kit proof" below). This PR puts back the notes in those files. | File | Dropped by | |---|---| | `install.sh`, `install.ps1` | #4040 | | `scripts/ci-runner-route.sh`, `scripts/windows-install.test.ps1` | #4047 | | `scripts/self-hosted-runner/run.sh`, `scripts/self-hosted-runner/build-cache-promote.sh`, `scripts/self-hosted-runner/hook-test-harness.sh`, `scripts/relay-ios-sim.sh` | #4049 | The notes were written against older code, so each one was read against the code beside it now. The second commit changes 12 that no longer matched, for example: - `run.sh`: the startup check covers the cgroup parent as well as the CPU list (#4061), and runners also mount their build cache outbox. - `install.sh`, `install.ps1`: the install lock is a pid file created only where none exists, not the folder. - `install.sh`: the herdr-core plugin build follows `herdr-plugin.toml`'s pre-flight step (#3800). - `windows-install.test.ps1`: the case reads `$state.badBinary`, not `releaseDown`. No code changes. One code line differs only in its comment: `install.ps1`'s `} catch { $job = [IntPtr]::Zero }` gets its trailing note back. No shellcheck or PSScriptAnalyzer directive comes back. ## Kit proof `~/.dori-sa/kit/refactor-merge/proof.sh 4115` at 4769efc ends with **FAIL**. Of the 8 files it proves 1 (`install.ps1`) and lists 7 as differing. Each one's first difference is "inside a string or heredoc": the kit's shell and PowerShell reader has lost track of the quoting by then and reads the restored comment as string text. This is the misread these files were held back for. Each file was checked again with the language's own parser, base 9df15d6 against this head: - `shfmt -mn` (shfmt 3.14.1's parser, which drops comments) prints the same output for `install.sh`, `ci-runner-route.sh`, `run.sh`, `build-cache-promote.sh` and `hook-test-harness.sh`. - `relay-ios-sim.sh`: two of its notes are inside the `remote.sh` heredoc, the script it runs on eamac. They are comments in that script, but text to this one. `shfmt -mn` gives the same output for the heredoc's script, and for the file with the heredoc emptied. - `install.ps1` and `windows-install.test.ps1`: PowerShell 7.6's `Parser.ParseFile` gives the same token list (comments and newlines left out) on both sides, 6,005 and 10,476 tokens. So this PR needs the owner's merge: the kit's rule is to merge only on PASS. ## Validation - `bun run check fast`: passed (18,673 unit tests, typecheck, build, generated themes and types). - `bash -n` on the six `.sh` files; `bun test scripts/conventions.test.ts`. - `git show HEAD~1 HEAD | grep -E '^[+-][^+-]' | grep -vE '^[+-]\s*#'` prints only that `install.ps1` line. Left open, not merged, on the owner's word. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ost has room (#4068) ## What `scripts/self-hosted-runner/run.sh --offer-when-room` (opt-in). A registered runner is an offer: GitHub hands it any job with matching labels, whatever its host is doing, so a busy host keeps taking work (one host's browser parts took 10.5 to 14.8 min against 8 elsewhere). With the flag, a slot that is not reserved waits, before it fetches a registration token, until the host has room: - no other runner of this host in the same pool is idle (a runner without a `Runner.Worker` process; the runners of every launcher copy on the host count), and no other slot of the pool has claimed room and not started yet: at most one idle offer per host and pool; - no job started on the host in the last 30 s and no runner started in the last 30 s (pressure shows up late); - `/proc/pressure/cpu` and `/proc/pressure/memory` "some avg10" are under `CHECK_HOST_OFFER_CPU_PSI` and `CHECK_HOST_OFFER_MEMORY_PSI` from the host env file (1 or more; skipped, with one log line, on a kernel without PSI). The decision and the claim happen under a host-wide `flock`; the state lives in `~/.cache/ovis-ci-runner`. Reserved slots (main's runners) are never gated. Without the flag nothing changes; `--count` stays the hard maximum and still has to fit `CHECK_HOST_MAX_RUNS`. ## Rollout Measured host by host: first one host, two hours of real pull-request runs against the hours before, taken back if worse; a host's first gated runner runs one real job under a label of its own before it joins the pool. ## Validation - `bun test scripts/self-hosted-runner.test.ts`: 91 pass, 7 skip (namespace-only hook tests). The gate's 15 tests fail without the code they cover (checked by reverting each part); the fake `docker top` refuses a format without a pid column, as Docker 29 does. - `docker top <runner> -eo pid,etimes,args` checked on the real runner containers of the maintainer PC: idle runners read as idle, busy ones give their job's age. - `bun run check fast` at this head (hosthatch heavy runner). - Reviews: four Codex (gpt-6.1-terra) rounds and three omo rounds before this head; last reads CLEAR at 1d2da1b2 (this head is that change rebased onto main after #4061 merged; the gate's diff is byte-identical). Fixed on the way: `docker top` needed a pid column (the gate saw nothing without it), claims that last until the container runs and are removed only under the lock, state not under `XDG_RUNTIME_DIR`, a 0 threshold refused, a bounded token request, a lock file that cannot be opened no longer ends a slot's loop. - Declined, with reasons in the reports: a transient `docker top` failure lets an offer through (the gate fails open by design, the worst case being the behaviour without it); a job that starts and ends between two polls is not waited out (it leaves no pressure). Pre-existing, not from this change: "mounts the build cache read-only ..." runs about 3.6 s against its 5 s timeout on main too and can time out under host load. --------- Co-authored-by: devswha <[email protected]>
What
scripts/self-hosted-runner/run.sh --cgroup-parent SLICEstarts every container the launcher starts(the runners, the check slots' keeper, the cache builds and helpers) and the image build's steps under that
cgroup instead of docker's own. With docker's systemd driver on cgroup v2, a host can then give its CI a low
CPU weight: the runners in
ovis-ci.sliceunder a top-levelovis.slicewithCPUWeight=20run at fullspeed while the CPU is free and yield to the PC's own sessions (weight 100) when both want it, instead of
being held back by a low runner count. A parent docker cannot use is refused at start (exit 2), before any
registration token, like a CPU list. Without the option nothing changes.
CPUSET_ARGSbecomesPLACE_ARGS, which carries--cpuset-cpusand--cgroup-parenttogether.Why now
Step 2 of measured CI placement work: the maintainer PC protects its owner's sessions by weight rather than
by a low runner count. Turning it on is a host change (the slice and the launcher's flag), measured on its
own; this pull request only adds the option.
Validation
--cgroup-parent ovis-ci.slicelands in
/ovis.slice/ovis-ci.slice/docker-<id>.scope. A contention probe (8 CPU-bound processes in anormal session beside 16 busy processes in a runner-image container, CPUs 120-127) took 2.5 s alone and
5.5 s beside the container at default weights; the weighted measurement follows when the slice gets its
weight.
bun run check fastat 77a1bd9 (hosthatch heavy runner): pass.bun test scripts/self-hosted-runner.test.ts: 76 pass; the new tests fail without the change.CLEAR at this head.