Skip to content

feat: add support to use custom scale errors - #4932

Merged
npalm merged 11 commits into
github-aws-runners:mainfrom
edersonbrilhante:feat-custom-scale-error
Jan 6, 2026
Merged

feat: add support to use custom scale errors#4932
npalm merged 11 commits into
github-aws-runners:mainfrom
edersonbrilhante:feat-custom-scale-error

Conversation

@edersonbrilhante

Copy link
Copy Markdown
Contributor

Summary

This PR makes the list of EC2 scaling error codes configurable instead of hardcoded in the control-plane Lambda. It allows users to extend or override the default retryable error set without forcing a change on everyone.

Motivation

Issue [#4105] was closed without a PR, leaving the scale error list hardcoded.
Different environments can encounter additional EC2 error codes that should trigger retries; making this list configurable lets users adapt behavior without modifying the library code.

@edersonbrilhante
edersonbrilhante marked this pull request as ready for review December 4, 2025 13:55
@edersonbrilhante
edersonbrilhante requested review from a team as code owners December 4, 2025 13:55
@edersonbrilhante
edersonbrilhante force-pushed the feat-custom-scale-error branch 2 times, most recently from c3b568d to 68f1f4b Compare December 4, 2025 14:04
@npalm

npalm commented Dec 13, 2025

Copy link
Copy Markdown
Member

@edersonbrilhante due to the update to the new 7.x release some breaking changes. Please can you rebase the PR? Thanks!

@edersonbrilhante

Copy link
Copy Markdown
Contributor Author

@npalm I tested and it is working fine :)

I added InsufficientFreeAddressesInSubnet in the custom_scale_errors

custom_scale_errors = [
      "UnfulfillableCapacity",
      "MaxSpotInstanceCountExceeded",
      "TargetCapacityLimitExceededException",
      "RequestLimitExceeded",
      "ResourceLimitExceeded",
      "MaxSpotInstanceCountExceeded",
      "MaxSpotFleetRequestCountExceeded",
      "InsufficientInstanceCapacity",
      "InsufficientFreeAddressesInSubnet", # Deployed in a short subnet to trigger this error
    ]

The logs(I redacted the valid ids) show it will was sent back to queue because accepted this error: InsufficientFreeAddressesInSubnet


{"level":"WARN","message":"Failed to create instance, create fleet failed. (Failed to create 12 instances) A retry will be attempted via SQS.","timestamp":"2025-12-16T12:59:03.030Z","service":"runners-scale-up","sampling_rate":0,"xray_trace_id":"1-00000000-000000000000000000000000","region":"eu-west-1","environment":"acme-standard","aws-request-id":"00000000-0000-0000-0000-000000000000","function-name":"acme-standard-scale-up","module":"lambda.ts","error":


{"name":"ScaleError","location":"file:///var/task/index.js:124990","message":"Failed to create instance, create fleet failed.","stack":"ScaleError: Failed to create instance, create fleet failed.\n    at processFleetResult (file:///var/task/index.js:124990:15)\n    at createRunner (file:///var/task/index.js:124946:29)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async createRunners (file:///var/task/index.js:131774:23)\n    at async scaleUp (file:///var/task/index.js:131912:27)\n    at async BufferedInvokeProcessor.scaleUpHandler [as handler] (file:///var/task/index.js:132732:36)\n    at async BufferedInvokeProcessor.processInvoke (file:///var/runtime/index.mjs:1092:22)\n    at async _Runtime.processSingleConcurrent (file:///var/runtime/index.mjs:1178:7)\n    at async _Runtime.start (file:///var/runtime/index.mjs:1165:7)\n    at async ignition (file:///var/runtime/index.mjs:1634:5)","failedInstanceCount":12}}


{"level":"WARN","message":"Create fleet failed, ScaleError will be thrown to trigger retry for ephemeral runners.","timestamp":"2025-12-16T12:59:03.030Z","service":"runners-scale-up","sampling_rate":0,"xray_trace_id":"1-00000000-000000000000000000000000","region":"eu-west-1","environment":"acme-standard","module":"runners","aws-request-id":"00000000-0000-0000-0000-000000000000","function-name":"acme-standard-scale-up","runner":{"ephemeral":true,"type":"Org","namePrefix":"","n_events":1}}
{"level":"WARN","message":"No instances created.","timestamp":"2025-12-16T12:59:03.029Z","service":"runners-scale-up","sampling_rate":0,"xray_trace_id":"1-00000000-000000000000000000000000","region":"eu-west-1","environment":"acme-standard","module":"runners","aws-request-id":"00000000-0000-0000-0000-000000000000","function-name":"acme-standard-scale-up","runner":{"ephemeral":true,"type":"Org","namePrefix":"","n_events":1},"data":{"$metadata":{"httpStatusCode":200,"requestId":"00000000-0000-0000-0000-000000000000","attempts":1,"totalRetryDelay":0},"FleetId":"fleet-00000000-0000-0000-0000-000000000000","Errors":[{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.medium","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.medium","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.large","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.large","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"m5.large","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"m5.large","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.xlarge","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.xlarge","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"m5.xlarge","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"m5.xlarge","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.2xlarge","SubnetId":"subnet-11111111111111111"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-11111111111111111' to satisfy the requested number of instances."},{"LaunchTemplateAndOverrides":{"LaunchTemplateSpecification":{"LaunchTemplateId":"lt-00000000000000000","Version":"16"},"Overrides":{"InstanceType":"t3.2xlarge","SubnetId":"subnet-00000000000000000"}},"Lifecycle":"on-demand","ErrorCode":"InsufficientFreeAddressesInSubnet","ErrorMessage":"There are not enough free addresses in subnet 'subnet-00000000000000000' to satisfy the requested number of instances."}],"Instances":[]}}

Comment thread lambdas/functions/control-plane/src/aws/runners.ts Outdated
npalm
npalm previously approved these changes Dec 18, 2025

@npalm npalm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@edersonbrilhante @guicaulada looks good to me. Left a commetn. But this approach is fine as well.

@npalm npalm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@edersonbrilhante thx for all the hard work, looks to to me

@npalm
npalm merged commit 5285cdc into github-aws-runners:main Jan 6, 2026
42 checks passed
npalm pushed a commit that referenced this pull request Jan 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.2.0](v7.1.0...v7.2.0)
(2026-01-06)


### Features

* add support to use custom scale errors
([#4932](#4932))
([5285cdc](5285cdc))
@ edersonbrilhante


### Bug Fixes

* **lambda:** bump qs from 6.14.0 to 6.14.1 in /lambdas
([#4978](#4978))
([e27ee7c](e27ee7c))
* **lambda:** bump the aws group in /lambdas with 7 updates
([#4971](#4971))
([9843662](9843662))
* **lambda:** bump the aws-powertools group in /lambdas with 4 updates
([#4972](#4972))
([e018a10](e018a10))

---
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>
@edersonbrilhante
edersonbrilhante deleted the feat-custom-scale-error branch January 11, 2026 11:52
LudovicTOURMAN pushed a commit to doctolib-lab/terraform-aws-github-runner that referenced this pull request Apr 7, 2026
## Summary
This PR makes the list of EC2 scaling error codes configurable instead
of hardcoded in the control-plane Lambda. It allows users to extend or
override the default retryable error set without forcing a change on
everyone.

## Motivation

Issue [github-aws-runners#4105] was closed without a PR, leaving the scale error list
hardcoded.
Different environments can encounter additional EC2 error codes that
should trigger retries; making this list configurable lets users adapt
behavior without modifying the library code.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
LudovicTOURMAN pushed a commit to doctolib-lab/terraform-aws-github-runner that referenced this pull request Apr 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.2.0](github-aws-runners/terraform-aws-github-runner@v7.1.0...v7.2.0)
(2026-01-06)


### Features

* add support to use custom scale errors
([github-aws-runners#4932](github-aws-runners#4932))
([5285cdc](github-aws-runners@5285cdc))
@ edersonbrilhante


### Bug Fixes

* **lambda:** bump qs from 6.14.0 to 6.14.1 in /lambdas
([github-aws-runners#4978](github-aws-runners#4978))
([e27ee7c](github-aws-runners@e27ee7c))
* **lambda:** bump the aws group in /lambdas with 7 updates
([github-aws-runners#4971](github-aws-runners#4971))
([9843662](github-aws-runners@9843662))
* **lambda:** bump the aws-powertools group in /lambdas with 4 updates
([github-aws-runners#4972](github-aws-runners#4972))
([e018a10](github-aws-runners@e018a10))

---
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>
zeekay pushed a commit to zeekay/terraform-aws-github-runner that referenced this pull request Sep 9, 2026
## Summary
This PR makes the list of EC2 scaling error codes configurable instead
of hardcoded in the control-plane Lambda. It allows users to extend or
override the default retryable error set without forcing a change on
everyone.

## Motivation

Issue [github-aws-runners#4105] was closed without a PR, leaving the scale error list
hardcoded.
Different environments can encounter additional EC2 error codes that
should trigger retries; making this list configurable lets users adapt
behavior without modifying the library code.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
zeekay pushed a commit to zeekay/terraform-aws-github-runner that referenced this pull request Sep 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.2.0](github-aws-runners/terraform-aws-github-runner@v7.1.0...v7.2.0)
(2026-01-06)


### Features

* add support to use custom scale errors
([github-aws-runners#4932](github-aws-runners#4932))
([bede2ff](github-aws-runners@bede2ff))
@ edersonbrilhante


### Bug Fixes

* **lambda:** bump qs from 6.14.0 to 6.14.1 in /lambdas
([github-aws-runners#4978](github-aws-runners#4978))
([d587d42](github-aws-runners@d587d42))
* **lambda:** bump the aws group in /lambdas with 7 updates
([github-aws-runners#4971](github-aws-runners#4971))
([65d303e](github-aws-runners@65d303e))
* **lambda:** bump the aws-powertools group in /lambdas with 4 updates
([github-aws-runners#4972](github-aws-runners#4972))
([91f044d](github-aws-runners@91f044d))

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

3 participants