diff --git a/docs/arm64-runner-dind.md b/docs/arm64-runner-dind.md index 4a15457..32a8b3f 100644 --- a/docs/arm64-runner-dind.md +++ b/docs/arm64-runner-dind.md @@ -1,9 +1,12 @@ # arm64 Forgejo runners on in-cluster dind — design and measured proof -Status: **design + measured proof only, nothing cut over** (kanban `t_627c231c`; -the cutover is `t_0da0a1cc`). Every number below was measured on `rpi` on -2026-10-27 between 05:30 and 05:55 EDT, in the temporary namespace -`runner-poc`, which was deleted afterwards (§2.7). +Status: **cut over 2026-10-27 — read §16 ("As-built") first for what is live, +then §1–§15 for the design and the measurements it was based on.** The design +half was kanban `t_627c231c`: every number in it was measured on `rpi` on +2026-10-27 between 05:30 and 05:55 EDT in the temporary namespace `runner-poc`, +which was deleted afterwards (§2.7). The cutover is `t_0da0a1cc`; §16 records +the applied manifests, the three deviations the cutover forced, the acceptance +evidence, and the executed rollback drill. **Recommendation: proceed — with three mandatory changes to the manifest, not just a socket swap.** The deciding number: a real `ci.yml`-shaped Rust job @@ -849,3 +852,250 @@ prune already reaches dind daemons by label (so it needs no change, only the `RpiDindDataRootFillingUp` at 70 % (`dind-disk-cap` group) — per-PVC bytes are simply not exported by kubelet 1.34+, so the filesystem is the only honest measure. + +--- + +## 16. As-built (cutover executed 2026-10-27, kanban `t_0da0a1cc`) + +Status: **cut over and verified in production.** Both arm64 runners execute +their job containers against an in-pod `docker:27-dind`; the Pi's host Docker is +no longer a job-container daemon for either. This section records what landed, +every deviation from §6/§15 with the evidence that forced it, the acceptance +output, and the rollback that was executed. + +### 16.1 What changed, per file + +| File | Change | +|---|---| +| `apps/base/forgejo/runner-arm64.yaml` | two-container pod (`dind` + `runner`); **zero hostPath**; `/data` on PVC, `/var/run` on emptyDir; dind `--mtu=1420 --insecure-registry=10.10.0.1:5000`, `limits.memory: 4Gi`; runner `runAsUser: 0` + socket-wait shim; `supplementalGroups: [984]` and the runner's `privileged: true`/`runAsGroup: 0` removed | +| `apps/base/forgejo/runner-deploy-arm64.yaml` | same shape; dind `limits.memory: 2Gi`; the `register` init container is replaced by `require-registration`, which exits 1 when `/data/runner.ini` is missing instead of burning a single-use token and creating a second `action_runner` row | +| `apps/base/forgejo/runner-dind-storage.yaml` (new) | `StorageClass local-static` (`kubernetes.io/no-provisioner`, `WaitForFirstConsumer`, `Retain`), PV+PVC `forgejo-runner-arm64-dind` 200Gi and `forgejo-runner-deploy-arm64-dind` 40Gi, `hostPath` under `/opt/local-path-provisioner/`, `nodeAffinity` to `rpi` | +| `apps/base/forgejo/runner-configmap.yaml` | `arm64.toml`: `runner.file: /data/runner.ini`, `cache: /data/cache`, CLI/plugins bound out of the dind image; `deploy-arm64.toml`: same options, comments corrected (no host socket, no host CLI) | +| `apps/base/forgejo/kustomization.yaml` | lists the storage file before the Deployments | +| `monitoring/controllers/home/prune-alerts.yaml` | new group `dind-disk-cap`, alert `RpiDindDataRootFillingUp` at **70 %** of rpi's `/` | +| Pi `/home/sirius/websites/docker-compose.yml` | `registry` publishes `10.10.0.1:5000:5000` **in addition to** `127.0.0.1:5000:5000`; backup `docker-compose.yml.orig-20261027-registry-wg` | +| `sirius/sirius-growth` `.forgejo/workflows/deploy-site.yml` | Pi-image push `127.0.0.1:5000` → `10.10.0.1:5000`; Garage endpoint `127.0.0.1:3900` → `10.10.0.1:3900` | + +Labels, verbatim and unchanged: shared `docker-arm64`, `arm64`, `docker` (all +`docker://node:20-bullseye`); deploy `deploy-arm64` only. `capacity = 1` on both. +The `dind` container is named exactly `dind` (§1.6 naming contract). + +### 16.2 Deviations from the design, and why + +1. **`--insecure-registry=10.10.0.1:5000` on both runners' dockerd.** §8 assumed + publishing the registry on the WG address was enough. It is not: Docker only + treats `127.0.0.0/8` as insecure by default, so the first post-cutover + `deploy-site` run (task 1732) built the Pi image fine and then died pushing it: + + ``` + #8 naming to 10.10.0.1:5000/***-growth-site:latest 0.0s done + The push refers to repository [10.10.0.1:5000/***-growth-site] + Get "https://10.10.0.1:5000/v2/": http: server gave HTTP response to HTTPS client + 🏁 Job failed + ``` + + Fixed on the daemon, not in the job image, so no workflow needs to know. + Proof afterwards: `docker info` inside each dind reports + `{"10.10.0.1:5000":{"Name":"10.10.0.1:5000","Secure":false,…}}` and the + re-run pushed `latest: digest: sha256:a819dc91…`. + +2. **Deploy runner dind limit is `2Gi`, not a copy of the amd64 runner's 4Gi.** + §15 left the number open. The Pi has ~7.0 GiB available and `capacity = 1` + bounds each runner but nothing bounds *both*: two 4 GiB limits would let a + `ci` run and a deploy claim every byte of the box. A deploy is two nginx-based + site images (112–143 MB) plus buildx's container driver and one amd64 + cross-build — nothing like the Rust job that measured 3.10 GiB. 4 GiB + 2 GiB + leaves ~1 GiB for kubelet/Cilium/cloudflared/host Docker in the overlap case, + and an OOM here fails one deploy *visibly*. + +3. **Measured pod MTU is 1500, not 1420.** `ip link show eth0` in the new pod + reports `mtu 1500` on rpi (the pod's default route leaves over the LAN + interface, not `wg0`). `--mtu=1420` is kept: it is below every path MTU this + pod uses, matches the amd64 runner, and the bridge really is 1420 + (`docker network inspect bridge` → `"com.docker.network.driver.mtu":"1420"`). + +4. **`runner.ini` at `/data/runner.ini` for both runners** (§6.4), copied from the + Pi host with `install -m 600 -o root -g root` *before* the first pod start. + Identity survived: uuid `4e07c1e9-4781-4241-bd8f-d5c10747cbd7` (action_runner + id 6 — its **name in the Forgejo DB is `pi-runner`**, not the `pi-arm64` the + ini file carries; the row was renamed historically) and + `a41aad73-5b18-4b58-be50-fc8b20807fc9` (id 14). No row was created, none was + orphaned: `action_runner` still has exactly three rows after the cutover. + +5. **The card's `grep -c docker.sock` = 0 acceptance cannot literally hold.** With + an in-pod daemon the socket is still `unix:///var/run/docker.sock` (in + `DOCKER_HOST`, the shim, and `container.options`), so the string appears 5× + per Deployment. The meaningful test is **no hostPath at all**: + `kubectl -n forgejo get deploy -o yaml | grep -c hostPath` = 0 for both, + and every `docker.sock` reference resolves to the `emptyDir` shared by the + `dind` and `runner` containers. + +6. **One in-flight CI job was killed by the `--insecure-registry` reconcile.** + `ci.yml` run 1192's second job (`sdk`, task 1734) had started at 06:53 and the + pod restart at 06:56 killed its container, leaving the task `running` with no + container and the run holding the workflow's concurrency group. Cleared the + dead rows (`action_task` 1734 → status 3, `action_run` 1192 → status 3; the + same rows the Forgejo UI would mark cancelled, since Forgejo exposes no cancel + endpoint) and re-dispatched. Proof run: `ci.yml` run **1197** — `test` task + 1737 green in **1782 s** (29m42s, warm `onionwire-target-ci`; the cold first + run was 3017 s) and `sdk` task 1738 green in **791 s** (13m11s — that job has + its own `onionwire-target-ci-sdk` volume, which was cold). + + **Cancelling a *queued* run in the DB does not stick.** Two extra + `ci.yml` dispatches queued behind the workflow's concurrency group + (`action_run.status = 5`); setting `status = 3` on a waiting row is undone the + next time Forgejo's scheduler wakes the queue, and the run then starts for + real. Kill it only once it is `status = 6` (running) with a dead task — i.e. + cancel the *task* first (set `action_task.status = 3` and its + `action_task_step` rows to 3), then the run. Runs 1192/1197/1198 are all + resolved that way and `select count(*) from action_run where status in (5,6)` + is now **0**. + +### 16.3 Acceptance evidence (all pasted from the live cluster) + +PVCs bound on rpi, static, `Retain`: + +``` +$ kubectl -n forgejo get pvc -o wide | grep dind +forgejo-runner-arm64-dind Bound forgejo-runner-arm64-dind 200Gi RWO local-static +forgejo-runner-deploy-arm64-dind Bound forgejo-runner-deploy-arm64-dind 40Gi RWO local-static +$ kubectl get pv forgejo-runner-arm64-dind forgejo-runner-deploy-arm64-dind +NAME CAPACITY RECLAIM POLICY STATUS CLAIM +forgejo-runner-arm64-dind 200Gi Retain Bound forgejo/forgejo-runner-arm64-dind +forgejo-runner-deploy-arm64-dind 40Gi Retain Bound forgejo/forgejo-runner-deploy-arm64-dind +``` + +Pods on rpi, two containers each, daemon `27.5.1` (the dind image — the Pi host +daemon is `29.7.2`, so a job can never be talking to it): + +``` +$ kubectl -n forgejo get deploy -o wide +forgejo-runner-arm64 1/1 dind,runner docker:27-dind,code.forgejo.org/forgejo/runner:5.0.1 +forgejo-runner-deploy-arm64 1/1 dind,runner docker:27-dind,code.forgejo.org/forgejo/runner:5.0.1 +$ kubectl -n forgejo exec -c dind -- docker version --format 'server={{.Server.Version}}' +server=27.5.1 +``` + +Registration identity, preserved, `last_online` current, no duplicates: + +``` +$ psql -Atc "select id,uuid,name,last_online,agent_labels from action_runner order by id" +6 |4e07c1e9-4781-4241-bd8f-d5c10747cbd7|pi-runner |1793080953|["docker-arm64","arm64","docker"] +8 |91124ee3-f344-44cf-9a07-11d6379549e8|siriussec-amd64 |1793080953|["docker-amd64","amd64"] +14|a41aad73-5b18-4b58-be50-fc8b20807fc9|pi-deploy-arm64 |1793080953|["deploy-arm64"] +``` + +Real jobs on the new runner ids — shared runner (`ci.yml`, `runs-on: docker`, +arm64): task 1731 green in 3017 s (cold `onionwire-target-ci`), then the rerun +task 1737 in 1782 s (warm); deploy runner: task 1736 (`deploy-site.yml`) green in +**48 s**, every step success, including the Pi-registry push and the Garage sync: + +``` +115 … #8 naming to 10.10.0.1:5000/***-growth-site:latest 0.0s done +174 … The push refers to repository [10.10.0.1:5000/***-growth-site] +203 … latest: digest: sha256:a819dc91cc3a2630cc355a40e8b5e5850879d0e429dd4c497572ae22446951cb size: 2619 +257 … upload: ../photos/scope/scope-market-1200.webp to s3://***-growth-photos/scope/scope-market-1200.webp +299 … 🏁 Job succeeded +``` + +Nightly prune reaches both new daemons (R10 proof, forced Job): + +``` +$ kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-1793084490 +$ kubectl -n forgejo logs job/prune-manual-1793084490 -c dind-daemons | grep -E "daemon: dind in pod/|summary:" +== daemon: dind in pod/forgejo-runner-amd64-f7bb99fb-mbv5f +== daemon: dind in pod/forgejo-runner-arm64-7c84998bb8-mmwqd +== daemon: dind in pod/forgejo-runner-deploy-arm64-5dcbd9f7fc-6nj2g +summary: dind daemons found=3 pruned=3 skipped=0 failed=0 +``` + +Pi registry scoped correctly (WG hub + loopback only; LAN and public closed): + +``` +$ ssh rpi 'ss -lntH "sport = :5000"' +LISTEN 0 4096 10.10.0.1:5000 0.0.0.0:* +LISTEN 0 4096 127.0.0.1:5000 0.0.0.0:* +$ ssh rpi 'curl -m5 -o /dev/null -w "%{http_code}" http://192.168.1.125:5000/v2/' → 000 (refused) +$ kubectl -n forgejo exec -c dind -- wget -qO- http://10.10.0.1:5000/v2/ +{} # from the job daemon itself +``` + +Disk guard live in Prometheus: + +``` +$ curl -s localhost:9090/api/v1/rules → dind-disk-cap / RpiDindDataRootFillingUp health=ok, state=inactive +$ → nodename=rpi value=0.5799 (57.99 % used, threshold 0.70) +``` + +Flux applied the change at `master@sha1:0a97d9305fd8adf07efa567b994c0754756142f3`; +`kubectl -n flux-system get kustomizations` → `apps`/`monitoring` `True` at that +revision. + +Disk, before → after: `/dev/sda2 917G, 490G used / 390G avail (56 %)` → +`496G used / 384G avail (57 %)`, with both dind data-roots now on the same +filesystem (`du -sh`: 5.2 G shared + 1.3 G deploy after the first jobs; steady +state is expected to reach ~146 G shared once the 141 GB of target volumes have +regrown inside dind — they rebuild cold by design, §4.2). + +### 16.4 What is still host-Docker dependent + +- **Nothing on the job path.** `onionwire` ci/fuzz/release and `sirius-growth` + `deploy-site` all execute against the in-pod daemon (a job's `docker version` + reports 27.5.1, the host's is 29.7.2). +- The **nightly prune** still mounts the Pi socket on purpose for its + `host-daemon` container: it is the cleanup path for the four host containers + that remain (`registry`, `garage`, `handyman-site`, `sirius-growth-site`). A + maintenance pod, not a job daemon. +- `/opt/siriusdevops` on the Pi is **kept, unused, as the rollback source** + (`runner/config/runner.ini`, `runner-deploy/data/runner.ini`, `docker-static`, + `cli-plugins`, the compose file). Nothing in the new Deployments reads it. +- The old host-daemon CI volumes (`onionwire-target-ci` 95.8 GB, `-sdk` 17.7 GB, + `-fuzz` 24.0 GB, `-aarch64` 3.2 GB) are **abandoned, not deleted** — that is the + rollback's warm cache, and it still occupies 141 GB on the Pi. +- Same host dependency as before, unchanged by design (§14): QEMU/binfmt is + kernel-global on the Pi, so the `--platform linux/amd64` cross build works + inside dind without an in-pod registration. + +### 16.5 Rollback (executed once, then re-applied) + +``` +# 1. stop the dind pods (a job container lives inside them, so it dies with them) +kubectl -n forgejo scale deploy/forgejo-runner-arm64 --replicas=0 +kubectl -n forgejo scale deploy/forgejo-runner-deploy-arm64 --replicas=0 +# 2. Flux owns these files: suspend the apps Kustomization, or the next +# reconcile puts the dind manifests straight back +flux -n flux-system suspend kustomization apps +# 3. restore the previous revision of the three files +git -C ~/Projects/homek8s show :apps/base/forgejo/runner-arm64.yaml | kubectl apply -f - +git -C ~/Projects/homek8s show :apps/base/forgejo/runner-deploy-arm64.yaml | kubectl apply -f - +git -C ~/Projects/homek8s show :apps/base/forgejo/runner-configmap.yaml | kubectl apply -f - +# 4. resume + reconcile to come back to the dind manifests +flux -n flux-system resume kustomization apps +``` + +**What the drill actually showed** (and what to do differently): + +- `kubectl apply -f ` does **not** remove the `dind` container — the + strategic merge keeps list items missing from the applied config. The rollback + came up with `containers: [dind, runner]` and the expected host socket + (`/var/run/docker.sock` as `srw-rw---- root 984`, `docker version` inside the + runner container reporting the **host** daemon 29.7.2, not 27.5.1), i.e. it + *worked* — but with a dead sidecar still in the pod. Use + `kubectl replace --force -f ` (or a real `git revert` + Flux + reconcile, which prunes correctly) if you want the pod spec literally back. +- Restoring the dind Deployments, the first pod start failed once with + `failed to start containerd: timeout waiting for containerd to start` (dockerd + exit 1) after the previous pod had been force-deleted, then succeeded on the + kubelet retry. If it ever loops, scale to 0 and clear + `/docker/containerd/daemon` while the pod is down — never while it runs + (the DiskPressure runbook rule). +- Identity survived the round trip unchanged: after restore the runner again + logs `runner: pi-runner, with labels: [docker-arm64 arm64 docker], declared + successfully` and `action_runner.last_online` is current for ids 6, 8 and 14. + +Verify after a rollback: pod `1/1 Running` on rpi, `action_runner.last_online` +moving for ids 6 and 14, and `ssh rpi docker ps` showing `GITEA-ACTIONS-*` +containers during the next job. The identity files exist in **two** places after +the cutover (Pi host + PV), which is exactly why the rollback needs no +re-registration in either direction. The PVs are `Retain`, so nothing is lost by +leaving them.