Skip to content

scaleset: refresh runners before autoscaling and mark scale sets created - #843

Draft
rm-you wants to merge 2 commits into
cloudbase:mainfrom
rm-you:fix/scaleset-delete-reconciliation
Draft

rm-you wants to merge 2 commits into
cloudbase:mainfrom
rm-you:fix/scaleset-delete-reconciliation

Conversation

@rm-you

@rm-you rm-you commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Two scale set worker fixes that #951 doesn't cover.

The runner list can go stale. The worker scales from its in-memory runner list, which it keeps current from database events. Start() reads the scale set's instances before it subscribes to instance events, with calls to GitHub in between, so a change in that window is never seen. A runner that finishes deleting then keeps its old entry, holds a max_runners slot until GARM restarts, and its deleted row is never cleaned up. Before each autoscaling tick, the worker now reloads the scale set's instances from the database and runs the existing cleanup on that list. If the reload fails, it skips the tick instead of scaling from a stale list. That's one query per scale set every 5 seconds.

Scale sets stay in pending_create. A scale set is stored as pending_create and nothing moves it to created. Start() now marks it created once it has made sure the scale set exists in GitHub. The state is informational, so a failed update is logged and doesn't stop the worker.

Earlier versions of this PR also changed how runners being deleted count toward the scaling target. #951 fixes that better, so that part is gone, and the two PRs no longer conflict.

Tests cover the reload replacing a stale entry, cleanup errors not stopping it, a stale runner being replaced exactly once, a failed reload skipping the tick for both scale-up and scale-down, and the state change.

🤖 Generated with Claude Code

@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 887c73e to 012b576 Compare August 18, 2026 07:32
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 012b576 to 0193ccc Compare August 27, 2026 03:43
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch 2 times, most recently from 3641b57 to 6a86205 Compare September 8, 2026 21:37
rm-you added a commit to rm-you/garm that referenced this pull request Sep 9, 2026
rm-you added a commit to rm-you/garm that referenced this pull request Sep 9, 2026
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 6a86205 to 1879875 Compare September 9, 2026 23:33
rm-you added a commit to rm-you/garm that referenced this pull request Sep 11, 2026
rm-you added a commit to rm-you/garm that referenced this pull request Sep 11, 2026
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 1879875 to 254968a Compare September 11, 2026 18:45
rm-you added a commit to rm-you/garm that referenced this pull request Nov 2, 2026
rm-you added a commit to rm-you/garm that referenced this pull request Nov 4, 2026
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 254968a to b0eca90 Compare November 4, 2026 01:21
rm-you added a commit to rm-you/garm that referenced this pull request Nov 9, 2026
rm-you added a commit to rm-you/garm that referenced this pull request Nov 15, 2026
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from b0eca90 to 414127c Compare November 15, 2026 06:52
rm-you added a commit to rm-you/garm that referenced this pull request Nov 15, 2026
rm-you and others added 2 commits November 15, 2026 07:44
The scale set worker decides how many runners to create or remove from
its in-memory runner list, which it keeps current from database events.
That list can go stale. Start() reads the scale set's instances before it
subscribes to instance events, with calls to GitHub in between, so a
change in that window is never seen. A runner that finishes deleting then
keeps its old entry, holds a max_runners slot until GARM restarts, and
its deleted row is never cleaned up.

Before each autoscaling tick, reload the scale set's instances from the
database and run the existing cleanup on that list. If the reload fails,
skip the tick instead of scaling from a stale list. This costs one query
per scale set every 5 seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A scale set is stored as pending_create, and nothing moves it to created,
so it reports pending_create forever, even after its worker has made sure
it exists in GitHub and is running. Mark it created once Start() has done
that. The state is informational, so a failed update is logged and does
not stop the worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rm-you rm-you changed the title scaleset: replace deleted runners scaleset: refresh runners before autoscaling and mark scale sets created Nov 15, 2026
@rm-you
rm-you force-pushed the fix/scaleset-delete-reconciliation branch from 414127c to 2944f2d Compare November 15, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant