Repository navigation
fix(scale-down): re-read the runner before deregistering instead of trusting the cycle snapshot - #5536
Open
andersjanmyr wants to merge 3 commits into
Open
fix(scale-down): re-read the runner before deregistering instead of trusting the cycle snapshot#5536andersjanmyr wants to merge 3 commits into
andersjanmyr wants to merge 3 commits into
Conversation
andersjanmyr
marked this pull request as ready for review
October 19, 2026 12:02
andersjanmyr
added a commit
to smrt/terraform-aws-github-runner
that referenced
this pull request
Oct 20, 2026
… terminating Review feedback on github-aws-runners#5536: - A runner whose compute resource disappeared during the cycle was skipped, leaving its registration behind on GitHub. It is now de-registered without a terminate call; nothing can be running on a resource that is gone. - DescribeInstances was called for every runner reaching the deregister path. The idle-confirmation window is now evaluated on the listed snapshot first, and the runner is only re-read when that evaluation would terminate it, so the call is paid once per termination rather than once per candidate. The current marker is re-evaluated only when it differs from the listed one. - The EC2 describe restricts to running and pending instances, matching list, and maps InvalidInstanceID.NotFound to "gone" instead of throwing. - Drop a duplicated key in the registry contract test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
andersjanmyr
added a commit
to smrt/terraform-aws-github-runner
that referenced
this pull request
Oct 20, 2026
… terminating Review feedback on github-aws-runners#5536: - A runner whose compute resource disappeared during the cycle was skipped, leaving its registration behind on GitHub. It is now de-registered without a terminate call; nothing can be running on a resource that is gone. - DescribeInstances was called for every runner reaching the deregister path. The idle-confirmation window is now evaluated on the listed snapshot first, and the runner is only re-read when that evaluation would terminate it, so the call is paid once per termination rather than once per candidate. The current marker is re-evaluated only when it differs from the listed one. - The EC2 describe restricts to running and pending instances, matching list, and maps InvalidInstanceID.NotFound to "gone" instead of throwing. - Drop a duplicated key in the registry contract test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rusting the cycle snapshot The cycle lists every runner once, then walks them with one or more GitHub calls each. On a fleet of 60+ runners the instance snapshot is a minute old by the time a runner is reached, which is long enough for a job-started hook to have tagged it ghr:bypass-removal, or for a parallel busy reading to have cleared its idle marker. Deregistering on the stale snapshot is how a runner gets terminated seconds into a job. ScaleDownComputeProvider gains describe(id), which returns the current state of one runner, or undefined when it no longer exists. The EC2 operations client backs it with DescribeInstances for that one instance; the template provider stubs it as not implemented. removeRunner calls describe after the not-busy reading and before deregistering: - a runner that no longer exists is skipped - a runner that now carries bypass-removal is skipped, since the job-started hook set the tag between the list call and this turn - the idle-confirmation window is evaluated on the current marker, not the listed one; a busy reading elsewhere that cleared the marker restarts the window instead of terminating on stale evidence Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… terminating Review feedback on github-aws-runners#5536: - A runner whose compute resource disappeared during the cycle was skipped, leaving its registration behind on GitHub. It is now de-registered without a terminate call; nothing can be running on a resource that is gone. - DescribeInstances was called for every runner reaching the deregister path. The idle-confirmation window is now evaluated on the listed snapshot first, and the runner is only re-read when that evaluation would terminate it, so the call is paid once per termination rather than once per candidate. The current marker is re-evaluated only when it differs from the listed one. - The EC2 describe restricts to running and pending instances, matching list, and maps InvalidInstanceID.NotFound to "gone" instead of throwing. - Drop a duplicated key in the registry contract test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The incremental EC2 cleanup tests (github-aws-runners#5463) swap in paged providers and legacy list fixtures without a describe stub, so the pre-deregister re-read saw every runner as vanished. A paged provider's describe now reports what its latest page listed. Also covers a vanished paged runner without a stored GitHub id: it is de-registered without persisting the id onto the missing instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andersjanmyr
force-pushed
the
fix/scale-down-reread-before-deregister
branch
from
November 19, 2026 13:35
8fe7ed1 to
e7967ca
Compare
Author
|
Rebased onto Two things changed while porting:
control-plane (515) and compute-providers (394) tests pass. eslint and The re-read has run in our CI fleet on v7.11.0 since October. We are about to deploy this rebased version on v8.1.1. |
This branch has not been deployed
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.
Description
Follow-up to #5397. The idle confirmation window fixes the stale
busyflag, but scale-down still decides on a stale instance snapshot:scaleDownlists every runner once, then walks them with one or more GitHub calls each. On a fleet of 60+ runners the snapshot is a minute old by the time a runner is reached. That is long enough for a job-started hook to have tagged the instanceghr:bypass-removal, or for a parallel busy reading to have cleared its idle marker, andremoveRunnerderegisters on what it listed. That is how we still saw runners terminated seconds into a job with the window enabled.This PR re-reads the runner right before deregistering:
ScaleDownComputeProvidergainsdescribe(id), returning the currentRunnerInfoorundefinedwhen the runner no longer exists.Ec2RunnerResourceOperationsgets the matchingdescribe, backed byDescribeInstancesfor that one instance and mapped through the samegetRunnerInfoaslist. The template provider stubs it as not implemented.removeRunnercalls it after the not-busy reading has passed the idle-confirmation window and beforedeleteGitHubRunner. A runner that now carriesbypass-removalis skipped. If the current idle marker differs from the listed one, the window is re-evaluated on the current marker, so a busy reading elsewhere that cleared the marker restarts the window rather than terminating on stale evidence. A runner whose compute resource is gone is still de-registered from GitHub, without a terminate call, so no registration is left behind.describerestricts to running/pending instances likelistdoes, and mapsInvalidInstanceID.NotFoundto "gone".Cost is one
DescribeInstancesper runner that would otherwise be terminated in this cycle, not per listed runner and not per candidate still inside the window. No IAM or Terraform changes.This composes with #5463: paging shrinks the staleness but a runner can still pick up a job between its page's list call and its turn.
Test Plan
yarn format-check,yarn lint,yarn test,yarn buildall green (671 tests across control-plane and compute-providers)scale-down.test.ts: runner tagged bypass-removal after the list call is not deregistered; runner that disappeared during the cycle is de-registered but not terminated; the window is decided on the current marker, not the list snapshot; no re-read while the window is still open. Provider contract test and EC2 capability/operations tests coverdescribe, including the NotFound mapping.scale_down_idle_confirmation_seconds = 300, this change on top of v7.11.0 plus feat(scale-down): opt-in idle confirmation window before terminating not-busy runners #5397) on 2026-10-19. Will report observations here.Related Issues
#5085, #5397, #5463
🤖 Generated with Claude Code