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

retry non-duplicate ec2 register_image errors #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions aminator/plugins/cloud/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ def _retry(f, *args, **kwargs):
_tries -= 1
_delay *= backoff
else:
log.critical("Unable to retry register_image due to ClientError: %s", e)
return False
# This could be a retryable error, such as ec2 api throttling
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the current crop of retry-able errors identifiable by either a specific exception or message in the exception?

What this effectively does is add an alternative path for ClientError exceptions wherein exception['Error']['Code'] does not match InvalidAMIName.Duplicate that catches all other forms, so if you're just looking to retry all exceptions from ClientError I might consider getting rid of the specific foo around checking for InvalidAMIName.Duplicate in the error code and just always retry ClientError exceptions (which is basically what your else: block does).

Copy link
Contributor

Choose a reason for hiding this comment

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

The bigger deal is if the exceptions thrown during registration are of some other type than ClientError...

_tries -= 1
if (_tries > 0):
log.critical("ClientError registering image, retrying: %s", e)
sleep(_delay)
_delay *= backoff
else:
log.critical("Unable to retry register_image due to ClientError: %s", e)
return False
log.critical('Failed to register AMI')
return False
return _retry
Expand Down Expand Up @@ -350,7 +357,7 @@ def is_stale_attachment(self, dev, prefix):
log.debug('{0} not stale, using'.format(dev))
return False

@registration_retry(tries=3, delay=1, backoff=1)
@registration_retry(tries=5, delay=2, backoff=2)
def _register_image(self, **ami_metadata):
"""Register the AMI using boto3/botocore components which supports ENA
This is the only use of boto3 in aminator currently"""
Expand Down Expand Up @@ -501,7 +508,7 @@ def _make_block_device_map(self, block_device_map, root_block_device, delete_on_
log.debug('Created BlockDeviceMapping [{}]'.format(bdm))
return bdm

@retry(FinalizerException, tries=3, delay=1, backoff=2, logger=log)
@retry(FinalizerException, tries=5, delay=2, backoff=2, logger=log)
def add_tags(self, resource_type):
context = self._config.context

Expand Down