feat(scale-down): sweep stopped warm instances - #5494
Open
Brend-Smits wants to merge 2 commits into
Open
Brend-Smits wants to merge 2 commits into
Brend-Smits wants to merge 2 commits into
Conversation
This was referenced Sep 30, 2026
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The sweep can terminate an instance concurrently being activated, leaving a job without a viable runner or cold fallback.
Review effort: Balanced
Findings: 1
What changed in this PR
Adds provider-level cleanup of stopped warm EC2 instances during every scale-down cycle.
Changes:
- Introduces the optional
sweepStandbycapability. - Removes activated or expired stopped warm instances with best-effort error handling.
- Adds registry, provider, and scale-down tests.
| File | Description |
|---|---|
lambdas/libs/compute-providers/registry.test.ts |
Verifies EC2 exposes standby sweeping. |
lambdas/libs/compute-providers/core/index.ts |
Extends the scale-down provider contract. |
lambdas/libs/compute-providers/aws/ec2/src/control-plane/scale-down.ts |
Implements stopped-instance sweeping. |
lambdas/libs/compute-providers/aws/ec2/src/control-plane/scale-down.test.ts |
Tests selection and failure handling. |
lambdas/libs/compute-providers/aws/ec2/control-plane.ts |
Connects standby operations to scale-down. |
lambdas/functions/control-plane/src/scale-runners/scale-down.ts |
Runs the sweep during scale-down. |
lambdas/functions/control-plane/src/scale-runners/scale-down.test.ts |
Tests orchestration and error isolation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Scale-down now destroys two kinds of stopped warm instances every cycle: - activated instances that stopped, for example after a job powered the machine off, which would otherwise stay stopped forever - instances past their `ghr:warm-expires-at` time, so standby instances are cleaned up even after warm mode is disabled and the pool lambda no longer evicts them Destroy cancels a persistent spot request before terminating. Errors are logged and never fail the scale-down run. Signed-off-by: Brend Smits <brend.smits@philips.com>
Scale-down sweeps stopped warm instances past ghr:warm-expires-at. A warm instance claimed shortly before its expiry could be destroyed by the sweep before scale-up started it. Scale-up now skips warm instances that expire within the activation grace period. Signed-off-by: Brend Smits <brend.smits@philips.com>
Brend-Smits
force-pushed
the
feat/warm-pool-04-scale-down-sweep
branch
from
October 1, 2026 12:27
71db0c7 to
26def47
Compare
Brend-Smits
force-pushed
the
feat/warm-pool-03-scale-up-activation
branch
from
October 1, 2026 12:27
b40a741 to
04b7e7f
Compare
Brend-Smits
marked this pull request as ready for review
October 1, 2026 13:58
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.

Warm pool stack (review in order; each PR is based on the previous one):
Description
Scale-down now destroys stopped warm instances every cycle:
ghr:warm-expires-attime, so standby instances are cleaned up even after warm mode is disabled and the pool lambda no longer evicts themDestroy cancels a persistent spot request before terminating. Errors are logged and never fail the scale-down run.
Test Plan
scale-down.test.tsin both packages andregistry.test.ts.vitest,tsc,eslintandprettierfor the affected lambda packages.Related Issues
Supersedes #5204.