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

EC2Metadata Available() hangs for 20s when not on EC2 #582

Closed
derekwaynecarr opened this issue Mar 8, 2016 · 2 comments
Closed

EC2Metadata Available() hangs for 20s when not on EC2 #582

derekwaynecarr opened this issue Mar 8, 2016 · 2 comments
Labels
guidance Question that needs advice or information.

Comments

@derekwaynecarr
Copy link

In the Kubernetes project, we use the following operation to detect if the cluster is running in an EC2 instance:

https://github.com/aws/aws-sdk-go/blob/master/aws/ec2metadata/api.go#L37

If the cluster is not running in an EC2 instance (for example, I am on bare-metal), this operation blocks and hangs for ~20s because it is unable to resolve the hostname of the metadata server. Since it can't resolve the hostname of the metadata server, it doesn't get an HTTP error since the connection can't even be established and the operation is retried until it has reached its max retry.

It would be good if the operation could either a) not retry, or b) fail quicker when dns name cannot be found.

For history:
kubernetes/kubernetes#22668

@xibz xibz added the guidance Question that needs advice or information. label Mar 8, 2016
@xibz
Copy link
Contributor

xibz commented Mar 8, 2016

Hello @derekwaynecarr, thank you for reaching out to us. You can disable retries by setting MaxRetries, in the config, to 0. Going to close this issue. If you have any more questions, please let us know.

sess := session.New(&aws.Config{
    Region:      aws.String("us-west-2"),
    MaxRetries: aws.Int(0),
})

In addition, this would apply to all requests. You can add this also to the client itself.

svc := ec2metadata.New(sess, &aws.Config {
    MaxRetries: aws.Int(0),
})

@xibz xibz closed this as completed Mar 8, 2016
@derekwaynecarr
Copy link
Author

@xibz thanks for the prompt assistance.

skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this issue May 20, 2021
Removes the old model generated lexruntimeservice package. Allows the
Smithy generated pkg to exist as a module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants