Repository navigation
Overlapping schedulers on by default, with a required drain limit - #411
Open
winding-lines wants to merge 2 commits into
Open
winding-lines wants to merge 2 commits into
winding-lines wants to merge 2 commits into
Conversation
OVERLAP moves into hetzner.env (synced to stack.conf; OVERLAP=0 opts out, a stack.conf without it overlaps). DRAIN_SECONDS is a new required setting: deploy.sh and up.sh refuse a missing, 0 or negative value before changing anything on the server, morca-stack apply refuses without it, and `morca scheduler` with MORCA_OVERLAP=on refuses to start without MORCA_DRAIN_SECONDS. The draining instance enforces the limit; reap-old and drain-old --wait stop an old scheduler still running past it (plus a grace), for ones started without the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6
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.
Closes #390
What changes
OVERLAPis a stack setting inhetzner.env, synced bydeploy.sh/up.sh(sync_settings) likeBACKUP_KEEP. It is on unlessOVERLAP=0, and astack.confwithoutOVERLAP(a server set up before this) overlaps too.can-overlapsaysno: OVERLAP=0 in stack.confwhen it's off.DRAIN_SECONDSis a new required setting inhetzner.env, with no default: how long, in seconds, an old scheduler may keep draining its runs after an overlapping deploy before it is stopped. The containers get it asMORCA_DRAIN_SECONDS.deploy.shandup.sh(need_settings→need_drain_limit) refuse a missing, empty, 0, negative or non-numeric value first, beforemorca-stackis sent or anything else changes on the server. The message names the setting and says what to set.morca-stack applyrefuses without it before it starts anything (a manual apply on the server), andconfiguretakes only a whole number above 0 for it, and only 0 or 1 forOVERLAP.morca schedulerwithMORCA_OVERLAP=onrefuses to start withoutMORCA_DRAIN_SECONDS(unset, 0, negative or not a number), before it migrates or touches the database (morca.instances.drain_limit).drain-oldreturns, and the old scheduler drains in the background until its runs end or the limit runs out.Where the limit is enforced (design call)
Scheduler._lead, as before withMORCA_DRAIN_SECONDS). It knows when its drain began, and at the limit it kills what's left (control runs' process groups too), ends its row and exits. Because the row is ended, the leader requeues the killed runs as soon as their heartbeats are stale, without waiting for the row to go stale.reap-oldreadsDRAIN_SECONDSfrom stack.conf anddocker stops an old scheduler that still runsMORCA_STACK_DRAIN_GRACE(60 s) past the limit. The limit is counted fromdrain-old, which comes after the instance began draining, so a scheduler that knows its limit always goes first. This covers old schedulers started without the limit: on a stack that already hadOVERLAP=1, the scheduler replaced by the first deploy after upgrading.drain-old --waitwithout--timeoutuses the same limit plus grace. Nothing is killed before the limit.MORCA_OVERLAPdefault staysoff. Only the stack turns overlap on by default. So a scheduler run by hand or in a test is one at a time and doesn't need a drain limit, and only an instance requires one.Upgrading (also in the changelog fragment and in docs/hetzner.md, "The drain limit")
Add
DRAIN_SECONDS=<seconds>tohetzner.envbefore the first deploy with these scripts. Until then,deploy.shstops withDRAIN_SECONDS isn't set: set DRAIN_SECONDS in <hetzner.env> ...and changes nothing. Overlap is then on unless you addOVERLAP=0:OVERLAP=1overlaps. The old scheduler it replaces was started without the limit, so its reaper stops it once the limit has run out.Tests
tests/hetzner.sh:applyandconfigurerefuse without a valid limit.deploy.shrefuses a missing, empty, 0, -5 or1hlimit, withmorca-stacknot sent, stack.conf unchanged and the tags unchanged.hetzner.envwithoutOVERLAPsetsOVERLAP=1, andMORCA_OVERLAP=onandMORCA_DRAIN_SECONDSreach morca.env.stack.confwithoutOVERLAPasks the image.OVERLAP=0fromhetzner.env,can-overlapsays no without asking the image,MORCA_OVERLAPis dropped and the deploy pauses. Taking it out again turns overlap back on.drain-old --waitandreap-oldstop an old scheduler at the limit.tests/hetzner-stacks.sh: the synced keys.tests/overlap.sh: the scheduler refuses to start without the limit (unset, empty, 0, -5,soon), before the database is migrated.tests/outdated.sh: runs with an hour's limit instead of none.Kept to the overlap and drain parts of these scripts, so that it merges cleanly with #410 (cgroups on by default). This PR merges after it.
🤖 Generated with Claude Code
https://claude.ai/code/session_017TycszSbyw92Efu4ZeCYL6