runner: drain in-flight jobs on SIGTERM instead of dying - #79
Merged
Merged
Conversation
launchd SIGTERMs the runner on every restart: the step-ca renewal's `kickstart -k`, a puppet reload's bootout. The runner died with it, and so did any job's `reprovision` subprocess -- mid-EACS that strands the host, quarantined, with its Hangar job never completed. SIGTERM now stops new claims (re-checked per claim, so a signal mid fill pass takes nothing new) and returns once in-flight jobs finish. launchd waits up to the plist's ExitTimeOut before SIGKILL; the ronin side raises that to cover a reprovision. Verified locally that `kickstart -k` delivers SIGTERM to the main process only and waits, leaving the child running. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
launchd sends SIGTERM to the runner on every restart: the step-ca cert renewal (
step ca renew --daemon --exec launchctl kickstart -k …), a puppet reload'sbootout, and a manual reload. The runner died immediately, and any in-flight job'sreprovisionsubprocess died with it. Mid-EACS, that strands the host quarantined and leaves its Hangar job open forever.What
stopis re-checked before every claim, so a SIGTERM that lands mid fill-pass doesn't start new work. One of the new tests caught that gap in the first version._serve(client, cfg, pool, stop). Behaviour is otherwise unchanged.Needs the ronin side: launchd only waits
ExitTimeOut(default 20s) before SIGKILL. The companion ronin PR raises it for the runner plist. The two are independent and either can merge first: each alone behaves exactly like today.Verified
kickstart -kdelivers SIGTERM to the main process only, blocks until it exits (up to ExitTimeOut), and the child keeps running during the drain._servestays alive until the in-flight job finishes (5/5 repeat runs)main()installs the handleropremoved from PATH; ruff is clean.🤖 Generated with Claude Code