Repository navigation
heavy: clean up everything a command started; heavy leftovers names the rest - #687
Conversation
…he rest heavy now removes its own scope's leftovers on every end: - a scope guard (a small setsid child that holds no queue ticket) stops the scope and removes its containers when heavy itself is killed, even with -9; - containers a command starts with the heavy owner label are removed when the command ends, is stopped or heavy is killed; a kept scope keeps them; - a command whose parent died is refused at once (double-forked children are stopped with the scope). `heavy leftovers [--older-than AGE] [--json]` looks only: it names processes, scopes and containers older than a limit, by owner and age, with default rules when there are no sweep settings. It never stops anything. Tests cover a killed heavy, a double-forked child, a container started by a command, a kept scope, missing or stopped Docker, and a rerun after a kill. Fixes #159 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review lens A (safety: what can it kill or remove?) — SAFEHead Blocking: none. What I checked and found safe
Minor
Not new and negligible, so no change asked: two live scopes drawing the same 8-hex suffix would make the second |
Review lens B (state and tests): SAFEI found nothing that loses data or breaks a run. CI is green: the real-systemd What I ran (locally, in a temp worktree):
State question
Major (tests: claimed behaviour that no test pins)
Minor
Real vs fake: Public diff: no personal paths, host names, VM ids, user names or emails. 🤖 Generated with Claude Code |
Tests pin what the guard and heavy's clean-up rely on: setsid (a kill -9 of heavy's process group), the guard ignoring heavy's signals, the parent-gone refusal, no guard for a kept scope, heavy's own exact label check, and the container removal on the signal path (grace time and second signal). Hardening: the guard is double-forked (a tree kill of heavy misses it); a stop by hand signals only pids still in the scope (pidfd + cgroup check) and kills with cgroup.kill; docker-label names the scope it is in, HEAVY_SCOPE only when the cgroup cannot be read; a Docker context counts as reachable; the sweep takes only an absolute HEAVY_DOCKER; heavy asks Docker only after a run that labelled a container. CI weight of sweep.test.py ~37s. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…he rest (#687) heavy now removes its own scope's leftovers on every end: - a scope guard (a small setsid child that holds no queue ticket) stops the scope and removes its containers when heavy itself is killed, even with -9; - containers a command starts with the heavy owner label are removed when the command ends, is stopped or heavy is killed; a kept scope keeps them; - a command whose parent died is refused at once (double-forked children are stopped with the scope). `heavy leftovers [--older-than AGE] [--json]` looks only: it names processes, scopes and containers older than a limit, by owner and age, with default rules when there are no sweep settings. It never stops anything. Tests cover a killed heavy, a double-forked child, a container started by a command, a kept scope, missing or stopped Docker, and a rerun after a kill. Fixes #159 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Tests pin what the guard and heavy's clean-up rely on: setsid (a kill -9 of heavy's process group), the guard ignoring heavy's signals, the parent-gone refusal, no guard for a kept scope, heavy's own exact label check, and the container removal on the signal path (grace time and second signal). Hardening: the guard is double-forked (a tree kill of heavy misses it); a stop by hand signals only pids still in the scope (pidfd + cgroup check) and kills with cgroup.kill; docker-label names the scope it is in, HEAVY_SCOPE only when the cgroup cannot be read; a Docker context counts as reachable; the sweep takes only an absolute HEAVY_DOCKER; heavy asks Docker only after a run that labelled a container. CI weight of sweep.test.py ~37s. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…he rest (#687) heavy now removes its own scope's leftovers on every end: - a scope guard (a small setsid child that holds no queue ticket) stops the scope and removes its containers when heavy itself is killed, even with -9; - containers a command starts with the heavy owner label are removed when the command ends, is stopped or heavy is killed; a kept scope keeps them; - a command whose parent died is refused at once (double-forked children are stopped with the scope). `heavy leftovers [--older-than AGE] [--json]` looks only: it names processes, scopes and containers older than a limit, by owner and age, with default rules when there are no sweep settings. It never stops anything. Tests cover a killed heavy, a double-forked child, a container started by a command, a kept scope, missing or stopped Docker, and a rerun after a kill. Fixes #159 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Tests pin what the guard and heavy's clean-up rely on: setsid (a kill -9 of heavy's process group), the guard ignoring heavy's signals, the parent-gone refusal, no guard for a kept scope, heavy's own exact label check, and the container removal on the signal path (grace time and second signal). Hardening: the guard is double-forked (a tree kill of heavy misses it); a stop by hand signals only pids still in the scope (pidfd + cgroup check) and kills with cgroup.kill; docker-label names the scope it is in, HEAVY_SCOPE only when the cgroup cannot be read; a Docker context counts as reachable; the sweep takes only an absolute HEAVY_DOCKER; heavy asks Docker only after a run that labelled a container. CI weight of sweep.test.py ~37s. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…he rest (#687) heavy now removes its own scope's leftovers on every end: - a scope guard (a small setsid child that holds no queue ticket) stops the scope and removes its containers when heavy itself is killed, even with -9; - containers a command starts with the heavy owner label are removed when the command ends, is stopped or heavy is killed; a kept scope keeps them; - a command whose parent died is refused at once (double-forked children are stopped with the scope). `heavy leftovers [--older-than AGE] [--json]` looks only: it names processes, scopes and containers older than a limit, by owner and age, with default rules when there are no sweep settings. It never stops anything. Tests cover a killed heavy, a double-forked child, a container started by a command, a kept scope, missing or stopped Docker, and a rerun after a kill. Fixes #159 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Tests pin what the guard and heavy's clean-up rely on: setsid (a kill -9 of heavy's process group), the guard ignoring heavy's signals, the parent-gone refusal, no guard for a kept scope, heavy's own exact label check, and the container removal on the signal path (grace time and second signal). Hardening: the guard is double-forked (a tree kill of heavy misses it); a stop by hand signals only pids still in the scope (pidfd + cgroup check) and kills with cgroup.kill; docker-label names the scope it is in, HEAVY_SCOPE only when the cgroup cannot be read; a Docker context counts as reachable; the sweep takes only an absolute HEAVY_DOCKER; heavy asks Docker only after a run that labelled a container. CI weight of sweep.test.py ~37s. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #159
What changes
setsidchild namedscope-guard. It holds no queue ticket and no other fd of the command.kill -9, the guard stops the scope and removes its containers, and printsheavy: heavy was killed: ....fork-kit.heavy.owner=uid=<uid>,scope=<unit>(fromheavy docker-label).HEAVY_KEEP=1) keeps its containers.inspect, and only then removes them, so it never touches containers it did not start.heavy leftovers [--older-than AGE] [--json]only looks.General vs project
heavy leftovers. A project's tests must label their own containers withheavy docker-labelto get removed. Unlabelled containers are only reported.State question (in tests)
kill -9on heavy stops the command, its double-forked child and its container. A queued heavy killed with -9 frees its reservation.heavy leftoversgives the same answer twice and changes nothing.Tests
sweep.test.py: 74 OK (1 skipped).queue.test.py: 70 OK.install.test.py: 16 OK.heavy.test.pywith real systemd: 40 OK, run twice.bin/heavy, taken fromgit archive origin/main fork-kit.leftoverssweep tests fail on the old kit, because it has noleftovers.🤖 Generated with Claude Code