Skip to content

Commit

Permalink
Add SnapshotCreationPerVolumeRateExceeded retries with a *slow* retry
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed May 4, 2021
1 parent 115c902 commit ce0b57a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions plugins/modules/ec2_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def _describe_snapshots(ec2, **params):
return paginator.paginate(**params).build_full_result()


# Handle SnapshotCreationPerVolumeRateExceeded separately because we need a much
# longer delay than normal
@AWSRetry.jittered_backoff(catch_extra_error_codes=['SnapshotCreationPerVolumeRateExceeded'], delay=15)
def _create_snapshot(ec2, **params):
# Fast retry on common failures ('global' rate limits)
return ec2.create_snapshot(aws_retry=True, **params)
Expand Down
8 changes: 3 additions & 5 deletions tests/integration/targets/ec2_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@
# that:
# - result is changed

# Wait at least 15 seconds between concurrent volume snapshots.
- name: Prevent SnapshotCreationPerVolumeRateExceeded errors
pause:
seconds: 15

- name: Take snapshot and tag it
ec2_snapshot:
volume_id: '{{ volume_id }}'
Expand Down Expand Up @@ -223,6 +218,9 @@
ResourcePrefix: '{{ resource_prefix }}'
loop: '{{ range(1, 6, 1) | list }}'
loop_control:
# Anything under 15 will trigger SnapshotCreationPerVolumeRateExceeded,
# this should now be automatically handled, but pause a little anyway to
# avoid being aggressive
pause: 10
label: "Generate extra snapshots - {{ item }}"

Expand Down

0 comments on commit ce0b57a

Please sign in to comment.