swarm_runner: runner-unit memory fence 6G/8G, and an override now fails the play (#20) #21

Merged
ben merged 2 commits from ben/fix/swarm-runner-fence-memory into main 2026-09-28 03:33:28 +00:00 AGit
Owner

Refs #20. This is the repo half; the issue stays open until the play has run on elitebook-03.

What was wrong

The fence on forgejo-runner-swarm.service was MemoryHigh=2G / MemoryMax=3G, sized for one job. The runner takes two at once, and on 2026-09-25 the two were throttled into swap thrash. A systemctl set-property had already raised the limit to 6G/8G, but its drop-ins (50-MemoryHigh.conf, 50-MemoryMax.conf) sort before 50-swarm-fence.conf, so the fence won.

What changes

  • The limits are role vars: swarm_runner_unit_memory_high (6G) and swarm_runner_unit_memory_max (8G). CPU/IO weights are unchanged.
  • The role removes the stale /etc/systemd/system.control/forgejo-runner-swarm.service.d/50-Memory*.conf drop-ins.
  • After the reload, the role asserts that systemd loaded the fence's values. An override now fails the play.
  • The role used to say resource directives apply on the next restart. They apply at the daemon-reload. The comments are corrected, the set-property --runtime hint is removed, and a fence change no longer prints the "restart manually" notice.
  • CHANGELOG entry.

Checked

All on local systemd 255 with throwaway user units, ansible-core 2.21.1:

  • Drop-in order: fence at 6G/8G plus control-dir 50-MemoryHigh.conf/50-MemoryMax.conf at 2G/3G loads 6G/8G.
  • Reload reaches the running unit: a running process went from live memory.high 2G to 6G on daemon-reload alone, same PID.
  • The assert, taken verbatim from the role: passes on the fence alone; fails with its message on a later-sorting 60-override.conf at 2G/3G; fails with its message on infinity.
  • ansible-playbook playbooks/swarm-runner.yml --syntax-check passes. ansible-lint reports nothing new.

Not run against elitebook-03. The host's system manager is assumed to behave like the local user manager.

Review

Three-axis review (standards, spec, failure path). No hard violations; the assert can fire. Follow-ups are in the second commit.

Known and left alone: the runner unit (8G) and the swarm user slice (10G) are separate cgroups, so their caps sum to 18G on a host with about 15G. Caps are not reservations, and the issue asked for 6G/8G. Nothing in the repo reserves memory for etcd (MemoryLow/MemoryMin); only CPU/IO weights protect it.

After merge

  1. make swarm-runner LIMIT=elitebook-distributed-server-03. No restart is needed.
  2. Confirm on the host: cat /sys/fs/cgroup/system.slice/forgejo-runner-swarm.service/memory.high should read 6442450944.
  3. Still open from the issue, not in this PR: the 4 GB swap on elitebook-03, and / at 96% on matou-dev-server-01.

🤖 Generated with Claude Code

Refs #20. This is the repo half; the issue stays open until the play has run on elitebook-03. ## What was wrong The fence on `forgejo-runner-swarm.service` was `MemoryHigh=2G` / `MemoryMax=3G`, sized for one job. The runner takes two at once, and on 2026-09-25 the two were throttled into swap thrash. A `systemctl set-property` had already raised the limit to 6G/8G, but its drop-ins (`50-MemoryHigh.conf`, `50-MemoryMax.conf`) sort before `50-swarm-fence.conf`, so the fence won. ## What changes - The limits are role vars: `swarm_runner_unit_memory_high` (`6G`) and `swarm_runner_unit_memory_max` (`8G`). CPU/IO weights are unchanged. - The role removes the stale `/etc/systemd/system.control/forgejo-runner-swarm.service.d/50-Memory*.conf` drop-ins. - After the reload, the role asserts that systemd loaded the fence's values. An override now fails the play. - The role used to say resource directives apply on the next restart. They apply at the daemon-reload. The comments are corrected, the `set-property --runtime` hint is removed, and a fence change no longer prints the "restart manually" notice. - CHANGELOG entry. ## Checked All on local systemd 255 with throwaway user units, ansible-core 2.21.1: - **Drop-in order:** fence at 6G/8G plus control-dir `50-MemoryHigh.conf`/`50-MemoryMax.conf` at 2G/3G loads 6G/8G. - **Reload reaches the running unit:** a running process went from live `memory.high` 2G to 6G on daemon-reload alone, same PID. - **The assert, taken verbatim from the role:** passes on the fence alone; fails with its message on a later-sorting `60-override.conf` at 2G/3G; fails with its message on `infinity`. - `ansible-playbook playbooks/swarm-runner.yml --syntax-check` passes. `ansible-lint` reports nothing new. **Not run against elitebook-03.** The host's system manager is assumed to behave like the local user manager. ## Review Three-axis review (standards, spec, failure path). No hard violations; the assert can fire. Follow-ups are in the second commit. Known and left alone: the runner unit (8G) and the swarm user slice (10G) are separate cgroups, so their caps sum to 18G on a host with about 15G. Caps are not reservations, and the issue asked for 6G/8G. Nothing in the repo reserves memory for etcd (`MemoryLow`/`MemoryMin`); only CPU/IO weights protect it. ## After merge 1. `make swarm-runner LIMIT=elitebook-distributed-server-03`. No restart is needed. 2. Confirm on the host: `cat /sys/fs/cgroup/system.slice/forgejo-runner-swarm.service/memory.high` should read `6442450944`. 3. Still open from the issue, not in this PR: the 4 GB swap on elitebook-03, and `/` at 96% on matou-dev-server-01. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The fence on forgejo-runner-swarm.service was MemoryHigh=2G/MemoryMax=3G,
sized for a single job. The runner takes two at once; on 2026-09-25 idss's
vue-tsc plus an 8-worker vitest were throttled into swap thrash on
elitebook-03. A `systemctl set-property` had already raised the limit to
6G/8G, but its drop-ins (50-MemoryHigh.conf, 50-MemoryMax.conf) sort before
50-swarm-fence.conf, so the fence silently won.

- Limits become role vars: swarm_runner_memory_high (6G) and
  swarm_runner_memory_max (8G).
- Remove the stale /etc/systemd/system.control 50-Memory*.conf drop-ins so
  the fence is the one source of truth.
- Assert that systemd loaded the fence's values after the reload.
- Update the set-property --runtime hint to the new values.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- The role said resource directives apply on the next restart. They do
  not: a daemon-reload writes them to the running unit's cgroup (measured
  on systemd 255, same process before and after). Correct the comments and
  the changelog, drop the now-pointless set-property hint, and stop the
  fence task from printing the "restart manually" notice.
- Say in defaults that a lowered limit lands on in-flight jobs at reload.
- Compare the loaded limits as strings, so "infinity" fails with the
  assert's message instead of a filter error.
- Rename the vars to swarm_runner_unit_memory_high/_max: the role has two
  fences and these govern the runner unit only. Point per-host tuning at
  host_vars.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ben merged commit 4b1752156c into main 2026-09-28 03:33:28 +00:00
Sign in to join this conversation.
No reviewers
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/matou-distributed-servers!21
No description provided.