Repository navigation
fix(pool): count registered offline runners within boot time - #5487
shinharaguchi wants to merge 4 commits into
Conversation
|
@shinharaguchi we need your commits to be signed, so it can be merged |
With JIT config the runner is registered in GitHub before the agent on the instance connects, so it can be reported as offline while it is still booting. The pool counted a runner as booting only when it was not registered yet, so such a runner was excluded without checking its boot time, and a frequently running pool could launch extra instances. Count a registered runner that is offline and not busy while it is within its boot time. Offline runners that are busy, have no busy value, or whose boot time has expired are still excluded. Related github-aws-runners#3799
Move the check for registered offline runners that are not busy into its own branch instead of excluding them from the "not idle" branch with a negated flag. Behaviour is unchanged. Drop the test case for a runner status without a busy value, since RunnerStatus.busy is required and the case could only be built with a type cast.
06cfcba to
edc8323
Compare
|
@edersonbrilhante Thanks for pointing that out! I've re-signed both commits, and they now show as verified. Please let me know if anything else is needed. |
|
We run organization-level ephemeral runners with |
|
Thanks for confirming this, @mcrawford-fms! Good to hear it reproduces with organization-level runners and @edersonbrilhante I checked that v8.1.0 still has the same pool counting behavior, so this fix still applies. If there is anything I can do to help get it into a release, such as rebasing, adding tests or updating docs, I'm happy to help. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to count booting offline runners toward EC2 pool capacity.
No open issues 🎉
What changed in this PR
This PR prevents unnecessary EC2 pool top-ups while registered runners are still starting, addressing the offline-runner behavior reported in #3799 and #3809.
Changes:
- Count registered, offline, non-busy runners toward pool capacity while within
RUNNER_BOOT_TIME_IN_MINUTES. - Add tests for booting, expired, and busy offline runners while preserving existing handling of other runner states.
| File | Description |
|---|---|
lambdas/libs/compute-providers/aws/ec2/src/control-plane/pool.ts |
Apply the boot-time check to registered offline, non-busy runners. |
lambdas/libs/compute-providers/aws/ec2/src/control-plane/pool.test.ts |
Cover offline runners within and beyond boot time, plus busy-runner exclusions. |
Review effort: Balanced
Description
A registered runner that is offline and not busy is now counted by the pool while it is within
RUNNER_BOOT_TIME_IN_MINUTES. Today the pool skips the boot time check for any registered runner that is not online and idle, so a frequently running pool can launch extra instances while the first runner is still starting.Root cause
With JIT config, the runner is registered in GitHub right after the EC2 instance is launched, before its agent connects. The example response of the JIT configuration endpoint and the observation in #3799 show such a runner as
{ busy: false, status: "offline" }.countAvailableEc2PoolRunnerstreats a runner as booting only when it is not in the GitHub status map. A registered offline runner falls into the "not idle in GitHub and NOT counted" branch instead.Change
Registered offline runners that are not busy get their own branch: counted while within the boot time, not counted after it. Online idle runners, busy runners and unregistered runners keep their existing handling. The check is based on runner status, so it also applies to non-JIT runners reported as offline within their boot time.
Logs
Pool size one, running every minute (instance IDs anonymised):
Test Plan
counts registered offline runners that are still booting. It fails onmainand passes with this change.does not count registered busy or offline runnersinto a busy case and an expired offline case, and added an offline busy case.yarn format,yarn lint,yarn testandyarn buildinlambdas/. All passed.Related Issues
Related #3799
Related #3809