Skip to content

fix: support runner subnets in the same availability zone - #5304

Open
Quindrix wants to merge 3 commits into
github-aws-runners:mainfrom
Quindrix:support-multiple-subnets-in-az
Open

Quindrix wants to merge 3 commits into
github-aws-runners:mainfrom
Quindrix:support-multiple-subnets-in-az

Conversation

@Quindrix

@Quindrix Quindrix commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR allows runner subnets to exist in the same AZ. It groups the configured subnets into safe combinations and distributes runner capacity across separate fleet requests. If a request encounters a retryable capacity failure, the remaining capacity is carried forward to the next available subnet combination.

It also adds the required ec2:DescribeSubnets permissions and updates the documentation to remove the previous requirement that every subnet must be in a different AZ. Dedicated-host and explicit subnet override behaviour remains unchanged.

Test Plan

  • Unit tests were added for subnet grouping, capacity distribution, and retryable failures. All 71 EC2 runner tests pass, along with the ESLint and Prettier checks.
  • Used these changes in our environment and were able to provide two subnets in the same AZ without issue.

Related Issues

Fixes #5297, and follows on from #2904

@Quindrix
Quindrix requested review from a team as code owners August 27, 2026 10:16
@edersonbrilhante

edersonbrilhante commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

@Quindrix
Quindrix force-pushed the support-multiple-subnets-in-az branch from 2b8c476 to 31889c7 Compare September 30, 2026 10:12
Group subnets into AZ-safe fleet requests and distribute capacity across them.
Carry retryable failures forward to alternative subnets and add the required
DescribeSubnets permissions.
@Quindrix
Quindrix force-pushed the support-multiple-subnets-in-az branch from 31889c7 to d9a2d68 Compare September 30, 2026 10:15
@Quindrix

Copy link
Copy Markdown
Contributor Author

@edersonbrilhante Apologies for the delay in getting this done. I've tested the rebased version in our environment and it's still working.

I see one of the checks is failing for a HTTP 500. I'm not able to re-trigger it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Default subnet-exhaustion handling and retry classification can prevent failover or cause excessive and duplicate fleet requests.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds AZ-safe subnet grouping and capacity distribution for EC2 runners using same-AZ subnets.

Changes:

  • Resolves subnet Availability Zones and creates safe fleet combinations.
  • Distributes capacity and carries retryable failures between combinations.
  • Adds IAM permissions, tests, and updated documentation.
File Description
variables.tf Updates subnet requirements.
README.md Regenerates root input documentation.
modules/​runners/​variables.tf Updates runner subnet description.
modules/​runners/​README.md Regenerates runner documentation.
modules/​runners/​pool/​policies/​lambda-pool.json Grants subnet lookup permission.
modules/​runners/​policies/​lambda-scale-up.json Grants subnet lookup permission.
modules/​multi-runner/​variables.tf Updates multi-runner subnet description.
modules/​multi-runner/​README.md Regenerates multi-runner documentation.
modules/​compute-providers/​aws/​ec2/​control-plane.tf Adds subnet permissions to v2 control planes.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​runners.ts Implements subnet AZ lookup.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​runners.test.ts Tests subnet lookup.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​control-plane/​scale-up.test.ts Tests grouping, allocation, and carry behavior.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​control-plane/​runner-creation.ts Implements AZ-safe allocation and failover.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​control-plane/​pool.ts Extends pool operation requirements.
lambdas/​libs/​compute-providers/​aws/​ec2/​src/​control-plane/​pool.test.ts Updates pool mocks for subnet lookup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


const allocations = buildSubnetAllocations(subnetSets, runnerParameters.numberOfRunners);
for (const allocation of allocations) {
const targetCapacity = allocation.targetCapacity + retryableCarry;
);
result.instances.push(...allocationResult.instances);
result.nonRetryableErrorCount += allocationResult.nonRetryableErrorCount;
retryableCarry = allocationResult.retryableErrorCount;
Comment on lines +286 to +288
const response = await ec2Client.send(new DescribeSubnetsCommand({ SubnetIds: subnetIds }), {
abortSignal: signal,
});
chore: merge upstream main into support-multiple-subnets-in-az

This branch has not been deployed

No deployments
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.

Support multiple subnets in the same AZ

4 participants