swarm host fence: container half — post-rootful-cutover, sandcastle containers are cgroup SIBLINGS of the etcd voter (D3 regression) #568

Closed
opened 2026-08-15 05:14:53 +00:00 by ben · 1 comment
Owner

Found while closing #467 (2026-08-15). The 2026-08-12 rootful-docker cutover on elitebook-03 moved job containers out of user-1500.slice: with the system docker daemon (systemd cgroup driver), every container — postgres-ha-etcd AND each sandcastle-* job container — gets its own scope directly under system.slice, all at the default CPUWeight=100. D3's "the etcd voter always wins" now holds for the HOST-MODE half only (#467's new unit fence); the container half — the dominant load — is unfenced and competes with the voter at equal weight.

Fix direction: pass resource bounds at container start in .sandcastle/run-swarm.sh (docker run --cpu-shares 40 --memory 10g --memory-reservation 8g --pids-limit 2048, mirroring the old user-slice fence values), or a --cgroup-parent=swarm.slice minted with the D3 values. Per-container flags are the smaller door: no daemon config change, no restart, applies from the next job container.

Why ready-for-session: run-swarm.sh is a protected .sandcastle/ path (#445) — swarm workers must not edit it.

Acceptance: a live sandcastle job container on elitebook-03 shows the bounded weights (systemctl show <scope> -p CPUWeight or cgroup files) while postgres-ha-etcd keeps default weight; offline test in the sandcastle suite asserting the docker-run flags.

Found while closing #467 (2026-08-15). The 2026-08-12 rootful-docker cutover on elitebook-03 moved job containers out of `user-1500.slice`: with the system docker daemon (systemd cgroup driver), every container — `postgres-ha-etcd` AND each `sandcastle-*` job container — gets its own scope directly under `system.slice`, all at the default `CPUWeight=100`. D3's "the etcd voter always wins" now holds for the HOST-MODE half only (#467's new unit fence); the container half — the dominant load — is unfenced and competes with the voter at equal weight. **Fix direction:** pass resource bounds at container start in `.sandcastle/run-swarm.sh` (`docker run --cpu-shares 40 --memory 10g --memory-reservation 8g --pids-limit 2048`, mirroring the old user-slice fence values), or a `--cgroup-parent=swarm.slice` minted with the D3 values. Per-container flags are the smaller door: no daemon config change, no restart, applies from the next job container. **Why ready-for-session:** `run-swarm.sh` is a protected `.sandcastle/` path (#445) — swarm workers must not edit it. **Acceptance:** a live sandcastle job container on elitebook-03 shows the bounded weights (`systemctl show <scope> -p CPUWeight` or cgroup files) while `postgres-ha-etcd` keeps default weight; offline test in the sandcastle suite asserting the docker-run flags.
Author
Owner

Close-report (agent under ADR 0174 — veto anytime; worked live from Ben's laptop, the one session with the elitebook door)

Landed (f088e96 + 5f2f183 on main):

  • .sandcastle/fence-lib.sh — swarm_fence_container bounds each sandcastle-* container at birth via docker update (no restart): --cpu-shares 320 --memory 10g --memory-swap 10g --memory-reservation 8g --pids-limit 2048 — the retired user-slice fence's values. Non-worker names are never touched (fencing the voter would invert D3). Best-effort, loud on failure, kill switch SWARM_FENCE=0.
  • Wired into run-swarm.sh as a self-terminating poller over the existing #435 birth-capture file — no second docker events stream, the wedge-check contract untouched.
  • Offline suite tests/fence-lib-test.sh: 16 green (stub docker, red-first).

Live acceptance, elitebook-03 — exactly why this ran from a session with the door; the stub could never have caught either lesson:

  1. docker update refuses a bare --memory ("Memory limit should be smaller than already set memoryswap limit") — --memory-swap now rides the cap.
  2. The daemon's shares→weight conversion is log-scaled (systemd driver) and treats 1024 as UNSET: probed 512→59, 320→41, 256→35 — 320 is the calibrated value.

Final kernel state on the running worker vs the voter:

worker: cpu.weight=41 memory.max=10G pids.max=2048
etcd:   cpu.weight=100 memory.max=max   (untouched)

The running worker was fenced by hand with the lib's exact command; every worker born from the next swarm run is fenced automatically — the run-swarm: D3 fence applied to sandcastle-… log line is the residual watch item.

## Close-report (agent under ADR 0174 — veto anytime; worked live from Ben's laptop, the one session with the elitebook door) **Landed** (`f088e96` + `5f2f183` on `main`): - `.sandcastle/fence-lib.sh` — `swarm_fence_container` bounds each `sandcastle-*` container at birth via `docker update` (no restart): `--cpu-shares 320 --memory 10g --memory-swap 10g --memory-reservation 8g --pids-limit 2048` — the retired user-slice fence's values. Non-worker names are never touched (fencing the voter would invert D3). Best-effort, loud on failure, kill switch `SWARM_FENCE=0`. - Wired into `run-swarm.sh` as a self-terminating poller over the existing #435 birth-capture file — no second `docker events` stream, the wedge-check contract untouched. - Offline suite `tests/fence-lib-test.sh`: 16 green (stub docker, red-first). **Live acceptance, elitebook-03** — exactly why this ran from a session with the door; the stub could never have caught either lesson: 1. `docker update` refuses a bare `--memory` ("Memory limit should be smaller than already set memoryswap limit") — `--memory-swap` now rides the cap. 2. The daemon's shares→weight conversion is log-scaled (systemd driver) and treats 1024 as UNSET: probed 512→59, 320→41, 256→35 — **320 is the calibrated value**. Final kernel state on the running worker vs the voter: ``` worker: cpu.weight=41 memory.max=10G pids.max=2048 etcd: cpu.weight=100 memory.max=max (untouched) ``` The running worker was fenced by hand with the lib's exact command; every worker born from the next swarm run is fenced automatically — the `run-swarm: D3 fence applied to sandcastle-…` log line is the residual watch item.
ben closed this issue 2026-08-15 06:00:20 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#568
No description provided.