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

resource/aws_elb_attachment: Retry ELB attachment on InvalidTarget error #8483

Merged
merged 2 commits into from
May 2, 2019

Conversation

jbarrick-mesosphere
Copy link
Contributor

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #7561

Changes proposed in this pull request:

  • Retry aws_elb_attachment create when AWS returns InvalidTarget because the instance is not running yet.

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/elb Issues and PRs that pertain to the elb service. labels Apr 29, 2019
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

hi @jbarrick-mesosphere thanks for handling this issue, and for your contribution. The approach looks good. I left a couple of suggestions around the practices used for timeouts and AWS error checking to help get this merged.

aws/resource_aws_elb_attachment.go Outdated Show resolved Hide resolved
err := resource.Retry(600*time.Second, func() *resource.RetryError {
_, err := elbconn.RegisterInstancesWithLoadBalancer(&registerInstancesOpts)

if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a pattern we use throughout the code base to help when checking against AWS errors. The non-nested error checks help readability and the helper isAWSErr wraps all the type assertion logic.

err := resource.Retry(10*time.Minute, func() *resource.RetryError {                                                                                                                         
    _, err := elbconn.RegisterInstancesWithLoadBalancer(&registerInstancesOpts)                                                                                                               
                                                                                                                                                                                              
    if isAWSErr(err, "InvalidTarget", "") {                                                                                                                                                   
      return resource.RetryableError(fmt.Errorf("Error attaching instance to ELB, retrying: %s", err))                                                                                        
    }                                                                                                                                                                                         
                                                                                                                                                                                              
    if err != nil {                                                                                                                                                                           
      return resource.NonRetryableError(err)                                                                                                                                                  
    }                                                                                                                                                                                         
                                                                                                                                                                                              
    return nil                                                                                                                                                                                
})   

aws/resource_aws_elb_attachment.go Outdated Show resolved Hide resolved
@nywilken nywilken added this to the v2.9.0 milestone May 1, 2019
@nywilken nywilken added the waiting-response Maintainers are waiting on response from community or contributor. label May 1, 2019
@jbarrick-mesosphere
Copy link
Contributor Author

Thanks for review @nywilken ! Addressed your comments.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label May 1, 2019
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

LGTM 👍 👍

@nywilken nywilken changed the title #7561 - Retry ELB attachment on InvalidTarget. resource/resource_aws_elb_attachment: Retry ELB attachment on InvalidTarget error May 2, 2019
@nywilken nywilken changed the title resource/resource_aws_elb_attachment: Retry ELB attachment on InvalidTarget error resource/aws_elb_attachment: Retry ELB attachment on InvalidTarget error May 2, 2019
@nywilken nywilken added the enhancement Requests to existing resources that expand the functionality or scope. label May 2, 2019
@nywilken nywilken merged commit c942fb8 into hashicorp:master May 2, 2019
nywilken added a commit that referenced this pull request May 2, 2019
@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/elb Issues and PRs that pertain to the elb service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
2 participants