Skip to content
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

Use AWSRetry on ec2 launch failures due to lack of capacity (InsuffienctInstanceCapacity) #1038

Closed
1 task done
briantist opened this issue Sep 20, 2022 · 5 comments · Fixed by #1039
Closed
1 task done
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type)

Comments

@briantist
Copy link
Contributor

Summary

Similar to #927

I've hit some errors in launching ec2 instances where AWS was out of capacity for the specific instance type in that AZ (InsuffienctInstanceCapacity), however, it failed with the boto default of 4 retries. Like other operations, it could be useful to have more than 4, and it would be nice to have consistency with the other operations.

I am not sure exactly where in the code this condition would be caught so I don't have a line to point to right now.

Issue Type

Feature Idea

Component Name

ec2_instance.py
ec2.py

Additional Information

The error was: botocore.exceptions.ClientError: An error occurred (InsufficientInstanceCapacity) when calling the RunInstances operation (reached max retries: 4): We currently do not have sufficient m6i.xlarge capacity in the Availability Zone you requested (us-east-1c). Our system will be working on provisioning additional capacity. You can currently get m6i.xlarge capacity by not specifying an Availability Zone in your request or choosing us-east-1a, us-east-1b, us-east-1d, us-east-1f.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module needs_triage plugins plugin (any type) labels Sep 20, 2022
@tremble
Copy link
Contributor

tremble commented Sep 20, 2022

My experience with InsuffienctInstanceCapacity is that waiting a few minutes wouldn't be sufficient. Have you experienced cases where you've been able to grab capacity after retrying?

@tremble
Copy link
Contributor

tremble commented Sep 20, 2022

An example of how to inject additional codes to retry can be found in ec2_vpc_net

    connection = module.client(
        'ec2',
        retry_decorator=AWSRetry.jittered_backoff(
            retries=8, delay=3, catch_extra_error_codes=['InvalidVpcID.NotFound']
        ),
    )

( Different error code needed ;) )

@briantist
Copy link
Contributor Author

My experience with InsuffienctInstanceCapacity is that waiting a few minutes wouldn't be sufficient. Have you experienced cases where you've been able to grab capacity after retrying?

Yes, this came from a CI pipeline I have (internal), after several tries, most of them did find capacity (it was probably launching a few dozen instances). In the end, these are test/molecule instances and the instance type isn't terrible important, so I changed from m6i to m6a and it was fine.

I do agree that retrying is not always going to work (or perhaps not even usually), but as long as the number of retries is not configurable by end users, it's difficult to deal with these things without making internal changes to the code, and I'd prefer that the number of internal retries is generally consistent.

softwarefactory-project-zuul bot pushed a commit that referenced this issue Sep 20, 2022
`ec2_instance` retry on `InsuffienctInstanceCapacity `

SUMMARY

Closes #1038
Expands the use of the AWSRetry decorator to include InsuffienctInstanceCapacity errors.

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_instance

Reviewed-by: Mark Chappell <None>
patchback bot pushed a commit that referenced this issue Sep 20, 2022
`ec2_instance` retry on `InsuffienctInstanceCapacity `

SUMMARY

Closes #1038
Expands the use of the AWSRetry decorator to include InsuffienctInstanceCapacity errors.

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ec2_instance

Reviewed-by: Mark Chappell <None>
(cherry picked from commit 0374961)
softwarefactory-project-zuul bot pushed a commit that referenced this issue Sep 22, 2022
[PR #1039/0374961a backport][stable-4] `ec2_instance` retry on `InsuffienctInstanceCapacity `

This is a backport of PR #1039 as merged into main (0374961).
SUMMARY

Closes #1038
Expands the use of the AWSRetry decorator to include InsuffienctInstanceCapacity errors.

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_instance

Reviewed-by: Jill R <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants