Repository navigation
feat(controller): serve several runner images from one controller - #57
Merged
Merged
Conversation
Failing tests for issue #15: pools routed by label, one GitHub scan per scope, pools isolated from each other, RUNNER_POOLS config with the single-pool variables as a shorthand, and a webhook for any pool label. They do not compile yet: the pool type and the new signatures land next.
6 tasks
A job is routed to the one pool label it asks for (canTake, without case), a JIT runner carries the label of its pool, Railway lists every pool's services in one listing and creates each from its pool's image and region, and the webhook wakes the loop for any pool label. Proved by the ghapp, railway and webhook tests (go test -race).
One JSON list of pools (label, image, prefix, max_runners, scopes and an optional region). The single-pool variables still load as one pool, and mixing the two is refused. Prefixes and labels must differ across pools so no pool can reap another's services or share its jobs. Proved by the config tests.
Each distinct scope is read once per cycle and each pool is planned from its own services and the jobs that ask for its label, so a pool at its maximum never blocks another. Alert marks are cleared once over all pools so a shared scope cannot re-alert a late job. Proved by the controller tests (go test -race ./...).
Kills the mutants on the new number and pool bounds, covers a failed reap and the per-cycle floors, splits RUNNER_POOLS parsing to keep CRAP under 10, folds Labels and Prefixes into one helper, and records the higher coverage baseline. Proved by the quality gate run locally: every check passes.
README and docs/deploy.md describe RUNNER_POOLS, the rules across pools, draining a pool before removing it, the per-pool create limit, and how to fold a separate Postgres controller into the main one. Checked: no mention of a second controller is left in README.md or docs/deploy.md, and README documents RUNNER_POOLS.
Each pool counts its own jobs now, so the cycle-wide count was filled and never read. Proved by go vet and go test -race.
Kills the last mutant on the per-cycle floor. Proved by the quality gate run locally.
parsilver
marked this pull request as ready for review
November 26, 2026 05:46
Contributor
Author
|
Reviewed: approve. The single-pool variables load exactly as before (same default prefix, same reaping), each pool only sees its own prefix, there is one list call per scope per cycle, and Nits for a follow-up:
|
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 #15
One controller now serves several runner images.
RUNNER_POOLSis a JSON list of pools, each with alabel,image,prefix,max_runners,scopesand an optionalregion. Each cycle reads every scope once, whichever pools list it, and gives each queued job to the pool whose label it asks for. The canTake rule, run across the pool labels, decides that.reconcile.Makethen runs once per pool, with that pool's own services, jobs and maximum. The single-pool variables still configure one pool unchanged.Acceptance
TestOneCycleServesEveryPoolFromItsOwnImageAndPrefixWithOneScanPerScopechecks the image, prefix, JIT label and region of each service. It also checks oneQueuedJobsand oneRunnerscall per scope, including a scope that two pools list.TestAPoolAtItsMaximumDoesNotBlockTheOtherPool. Isolation is also covered byTestAPoolNeverReapsOrCountsAnotherPoolsServices,TestAnIdleRunnerOfOnePoolIsNoSupplyForTheOtherPoolandTestAnExitedServiceIsReapedOncePerCycle.queuedevent for either label starts a cycle.TestAQueuedWebhookForEitherPoolsLabelStartsACyclein the controller andTestAQueuedJobWithAnyPoolLabelNudgesTheControllerin the webhook. Labels now match without case, as the job scan already did.TestTheSinglePoolVariablesLoadAsOnePool. The existing config tests pass with only the field paths changed.TestRunnerPoolsIsRefusedWhenMalformedNamingTheVariablecovers a shared prefix, a shared label (compared without case), the reserved labels, and malformed pools. The existing prefix rule already stops one prefix from being the start of another.TestRunnerPoolsCannotBeMixedWithTheSinglePoolVariablescovers setting both kinds of configuration at once.RUNNER_POOLSentry and adds "Moving from two controllers to one".grep -i "second controller" README.md docs/deploy.mdfinds nothing.An independent plan review found these gaps, now fixed and tested:
TestALateJobIsAlertedOnceWhenTwoPoolsShareItsScope).TestAnotherPoolsNewRunnerDoesNotHideALateJob).TestAnUnreadableSharedScopeCountsOnceAndNoPoolTouchesItsServices).Commands run
Gate numbers
.quality/baseline.jsonis updated. Every changed line is covered except four wiring lines infunc main, which are waived below.main56 (base 56),Load17 (base 25),parseScope11 (base 11),alertLate14 (base 17).Waivers
Equivalent mutant: cmd/controller/main.go:29 wiring inside func main, which no test can run; the labels it passes come from Config.Labels, which the config tests cover
Equivalent mutant: cmd/controller/main.go:34 wiring inside func main, which no test can run; the prefixes it passes come from Config.Prefixes, which the config tests cover
Equivalent mutant: cmd/controller/main.go:46 wiring inside func main, which no test can run; the controller tests build the same Config with pools
Equivalent mutant: cmd/controller/main.go:52 wiring inside func main, which no test can run; the webhook and controller tests cover a handler given every pool label
Equivalent mutant: internal/config/config.go:33 only the capacity hint of a slice that append grows anyway, so no output changes
Risks
runs-on: Railwayjob now wakes the controller sooner; before, it waited for the poll. A label ofself-hosted,linuxorx64is refused at start; such a label could never route jobs correctly anyway.RUNNER_POOLSstrands its leftover services, since its prefix is no longer listed. The docs say to drain a pool first.MAX_CREATE_PER_CYCLEnow applies per pool, so N pools can create up to N times that many services in one cycle. Railway calls rise by the same factor in a burst.Not verified
controller upline should list both pools, then jobs of both labels should get runners.