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

Retries after timeouts on spot resources #9078

Merged
merged 1 commit into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
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: 7 additions & 8 deletions aws/resource_aws_spot_fleet_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,22 +703,21 @@ func resourceAwsSpotFleetRequestCreate(d *schema.ResourceData, meta interface{})
// take effect immediately, resulting in an InvalidSpotFleetRequestConfig error
var resp *ec2.RequestSpotFleetOutput
err = resource.Retry(10*time.Minute, func() *resource.RetryError {
var err error
resp, err = conn.RequestSpotFleet(spotFleetOpts)

if isAWSErr(err, "InvalidSpotFleetRequestConfig", "") {
return resource.RetryableError(fmt.Errorf("Error creating Spot fleet request, retrying: %s", err))
}
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// IAM is eventually consistent :/
if awsErr.Code() == "InvalidSpotFleetRequestConfig" {
return resource.RetryableError(
fmt.Errorf("Error creating Spot fleet request, retrying: %s", err))
}
}
return resource.NonRetryableError(err)
}
return nil
})

if isResourceTimeoutError(err) {
resp, err = conn.RequestSpotFleet(spotFleetOpts)
}

if err != nil {
return fmt.Errorf("Error requesting spot fleet: %s", err)
}
Expand Down
5 changes: 4 additions & 1 deletion aws/resource_aws_spot_instance_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface

var resp *ec2.RequestSpotInstancesOutput
err = resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = conn.RequestSpotInstances(spotOpts)
// IAM instance profiles can take ~10 seconds to propagate in AWS:
// http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#launch-instance-with-role-console
Expand All @@ -193,6 +192,10 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface
return resource.NonRetryableError(err)
})

if isResourceTimeoutError(err) {
resp, err = conn.RequestSpotInstances(spotOpts)
}

if err != nil {
return fmt.Errorf("Error requesting spot instances: %s", err)
}
Expand Down