Repository navigation
fix(lambda): fail-open isJobQueued — assume queued on API errors - #5130
edersonbrilhante merged 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR makes the job-queued verification in scaleUp resilient to GitHub API failures by switching the isJobQueued check to a fail-open approach, and adds a test to validate the new behavior.
Changes:
- Wrap
isJobQueuedin a try/catch and proceed with scaling when the check fails (fail-open). - Add a GHES unit test ensuring runners are still created when
isJobQueuedthrows.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lambdas/functions/control-plane/src/scale-runners/scale-up.ts | Makes the isJobQueued gate fail-open on errors to avoid dropping scale events during GitHub API issues. |
| lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts | Adds coverage for the new fail-open behavior when GitHub API calls fail. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edersonbrilhante
left a comment
There was a problem hiding this comment.
@vegardx Please sign your commits :)
Wrap the isJobQueued check in a try/catch that assumes the job is still queued when the GitHub API returns an error (404, rate limit, 502). This prevents silent job drops when the API is transiently unavailable. Previously, any error from getJobForWorkflowRun would propagate up and (combined with the non-ScaleError catch behavior) cause the entire SQS batch to be dropped. Fixes github-aws-runners#5026
Log only message and status instead of the full error object to avoid leaking request/response metadata from Octokit errors.
5f37318 to
330b56d
Compare
|
Signed and rebased onto current main. Sorry for the delay. |
The fail-open catch swallowed the "Event ... is not supported" error from isJobQueued, which meant a check_run event would silently scale up a runner. The eventType guard earlier in scaleUp only rejects non-workflow_job events when ephemeral runners are enabled, so this path is reachable in any non-ephemeral deployment with the queued-check on. Give that case its own error type and let it propagate, restoring the pre-change behaviour. Fail-open still applies to genuine API failures, which is what the change was for.
|
Copilot's review point was right, and it caught a regression I'd introduced — pushed a fix. The It now has its own error type and propagates, restoring the previous behaviour for that case. Fail-open still applies to genuine API failures, which is the point of the PR. Test included, and it fails against the previous version. On the other two: auth/permission failures I'd argue belong in fail-open. They're usually transient (token mint races, brief 401s during rotation), and the cost of being wrong is one idle runner that scales back down, versus a silently dropped job. 404 job-not-found is the genuinely debatable one. It can mean the job was cancelled — where failing open wastes a runner — or that we're reading right after the webhook and GitHub hasn't caught up, which is the race in #5026. I've left it failing open because dropping a real job seemed worse than briefly starting a surplus runner, but that's a judgement call rather than something I derived. Happy to narrow it to 5xx/429/network if you'd rather be conservative. |
🤖 I have created a release *beep* *boop* --- ## [7.10.1](v7.10.0...v7.10.1) (2026-07-31) ### Bug Fixes * **control-plane:** discard malformed SQS messages ([#5219](#5219)) ([8ca5816](8ca5816)) * enable Octokit throttle retry and SSM adaptive retry under burst ([#5136](#5136)) ([cbdd916](cbdd916)), closes [#5135](#5135) * **lambda:** bump axios from 1.17.0 to 1.18.0 in /lambdas ([#5211](#5211)) ([67bfdf8](67bfdf8)) * **lambda:** bump js-yaml from 3.14.2 to 3.15.0 in /lambdas ([#5212](#5212)) ([facea4e](facea4e)) * **lambda:** bump postcss from 8.5.15 to 8.5.22 in /lambdas ([#5231](#5231)) ([8ee045d](8ee045d)) * **lambda:** fail-open isJobQueued — assume queued on API errors ([#5130](#5130)) ([8fa06ee](8fa06ee)) * **scale-up:** return partial runner creation results ([#5220](#5220)) ([9045340](9045340)) * stop a malformed SQS body from poisoning the whole batch ([#5215](#5215)) ([69e06b1](69e06b1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
Problem
When
enable_job_queued_check = true(default), theisJobQueuedcall has no error handling. IfgetJobForWorkflowRunthrows (404, rate limit, 502), the error propagates up throughscaleUpand hits the generic catch inscaleUpHandler— causing the batch to fail.This is especially problematic in combination with the race condition described in #5026: when SQS delivers messages in multiple batches due to concurrency limits, GitHub API errors during the second batch cause jobs to be silently dropped.
Fix
Wrap the
isJobQueuedcheck in a try/catch. On any error, assume the job is still queued (fail-open) and log a warning. The worst case is creating a runner for a job that has already been handled — the runner will self-terminate when no job is available.Changes
lambdas/functions/control-plane/src/scale-runners/scale-up.ts— try/catch around isJobQueuedlambdas/functions/control-plane/src/scale-runners/scale-up.test.ts— test: API error → runner still createdRisk
Low — fail-open is strictly more resilient than fail-closed for job dispatch. The extra runner (if the job was already handled) self-terminates with no work.
Fixes #5026