-
Notifications
You must be signed in to change notification settings - Fork 89
Retry a throttled CreateFleet only when its other errors are pool-scoped #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hehe7318
merged 2 commits into
aws:develop
from
hehe7318:wip/throttling-pool-level-retry
Sep 18, 2026
+130
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| from common.utils import setup_logging_filter | ||
| from retrying import retry | ||
| from slurm_plugin.common import print_with_count | ||
| from slurm_plugin.slurm_resources import SlurmNode | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -41,6 +42,21 @@ | |
| "Failed to fulfill capacity. Please review errors in the response.", | ||
| ) | ||
|
|
||
| # Errors confined to one instance type and subnet pool. Reported alongside throttling, they leave the throttled | ||
| # pools able to serve the batch once the rate limit refills, so the throttling is still retried. Any other error | ||
| # alongside throttling would fail the retry on every pool alike and is reported instead. | ||
| POOL_LEVEL_ERROR_CODES = frozenset( | ||
| SlurmNode.EC2_ICE_ERROR_CODES | ||
| | { | ||
| "InsufficientFreeAddressesInSubnet", | ||
| "InvalidSubnetID.NotFound", | ||
| "InvalidSubnet", | ||
| "InsufficientVolumeCapacity", | ||
| "VolumeTypeNotAvailableInZone", | ||
| "ServiceUnavailable", | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class EC2Instance: | ||
| def __init__(self, id, private_ip, hostname, all_private_ips, launch_time): | ||
|
|
@@ -450,14 +466,27 @@ def _launch_instances(self, launch_params): | |
| ] | ||
| if real_errors: | ||
| err_list = real_errors | ||
| # A single cause is normally left. Should there be several, prefer throttling as a safety net: it is | ||
| # the only cause that resolves on its own, and reporting it as insufficient capacity would instead | ||
| # fail the compute resource over. | ||
| # A single cause is normally left. Should there be several, throttling is retried only when every | ||
| # other cause is confined to a pool, since the throttled pools can then still serve the batch once the | ||
| # rate limit refills. Any other cause would fail the retry on every pool alike and is reported instead. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you specify an example in the comment of an error that when mixed with the throttling will not trigger a retry?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added: |
||
| # For example: | ||
| # - [RequestLimitExceeded, InsufficientInstanceCapacity] -> retry, other pools can still serve the batch | ||
| # - [RequestLimitExceeded, VcpuLimitExceeded] -> report VcpuLimitExceeded, a retry hits the same limit | ||
| throttling = next( | ||
| (err for err in err_list if err.get("ErrorCode") == LAUNCH_THROTTLING_ERROR_CODE), None | ||
| ) | ||
| if throttling: | ||
| raise LaunchInstancesError(throttling.get("ErrorCode"), throttling.get("ErrorMessage")) | ||
| blocking = next( | ||
| ( | ||
| err | ||
| for err in err_list | ||
| if err.get("ErrorCode") != LAUNCH_THROTTLING_ERROR_CODE | ||
| and err.get("ErrorCode") not in POOL_LEVEL_ERROR_CODES | ||
| ), | ||
| None, | ||
| ) | ||
| chosen = blocking or throttling | ||
| raise LaunchInstancesError(chosen.get("ErrorCode"), chosen.get("ErrorMessage")) | ||
| # Normally a single cause is left. Reporting the first one of several is a second safety net: the | ||
| # caller otherwise records a hardcoded InsufficientInstanceCapacity, and any code EC2 actually | ||
| # returned is more useful than an invented one, whichever of them the response happens to list first. | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen this error code. Always seen something like
InvalidSubnetSOMETHING.Where did we get this error code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it from EC2 public doc:
https://docs.aws.amazon.com/ec2/latest/devguide/errors-overview.html
Search
InvalidSubnetin it. And you get: