Add retry mechanism to amazon DeleteSnapshot (#8614)

pull/8623/head
Sylvia Moss 6 years ago committed by GitHub
parent 0677b02e18
commit 39c25b2c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,8 +50,18 @@ func DestroyAMIs(imageids []*string, ec2conn *ec2.EC2) error {
// Delete snapshot(s) by image
for _, b := range i.BlockDeviceMappings {
if b.Ebs != nil && aws.StringValue(b.Ebs.SnapshotId) != "" {
_, err := ec2conn.DeleteSnapshot(&ec2.DeleteSnapshotInput{
SnapshotId: b.Ebs.SnapshotId,
err = retry.Config{
Tries: 11,
ShouldRetry: func(err error) bool {
return isAWSErr(err, "UnauthorizedOperation", "")
},
RetryDelay: (&retry.Backoff{InitialBackoff: 200 * time.Millisecond, MaxBackoff: 30 * time.Second, Multiplier: 2}).Linear,
}.Run(ctx, func(ctx context.Context) error {
_, err := ec2conn.DeleteSnapshot(&ec2.DeleteSnapshotInput{
SnapshotId: b.Ebs.SnapshotId,
})
return err
})
if err != nil {

Loading…
Cancel
Save