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

AWS_METADATA_TIMEOUT configuration environment variable #950

Merged
merged 1 commit into from
Jun 29, 2017
Merged

AWS_METADATA_TIMEOUT configuration environment variable #950

merged 1 commit into from
Jun 29, 2017

Conversation

handlerbot
Copy link
Contributor

We have a custom Terraform authentication server which impersonates the EC2 metadata API endpoint, but our use and implementation would benefit from being able to boost the 100ms API endpoint timeout in our environment.

Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

Hi @handlerbot,

Thanks for your work here!
While it seems good, I left a few comments for code cosmetic & log cosmetic!

// Keep the timeout low as we don't want to wait in non-EC2 environments
client.Timeout = 100 * time.Millisecond
// Keep the default timeout low as we don't want to wait in non-EC2 environments
timeoutMillis := 100
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of calling this defaultTimeout and rename timeoutString as userTimeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like userTimeout, but I think I'll go with timeoutMillis -> timeout rather than defaultTimeout. Once a value from the user is assigned to the variable, it's no longer the the default, no? :-)

client.Timeout = 100 * time.Millisecond
// Keep the default timeout low as we don't want to wait in non-EC2 environments
timeoutMillis := 100
timeoutString := os.Getenv("AWS_METADATA_TIMEOUT_MILLISECONDS")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set the env variable name as a constant for reusability here and in the log

@@ -113,6 +113,9 @@ which reduces the chance of leakage.
You can provide the custom metadata API endpoint via the `AWS_METADATA_ENDPOINT` variable
which expects the endpoint URL, including the version, and defaults to `http://169.254.169.254:80/latest`.

The default deadline for the EC2 metadata API endpoint is 100 milliseconds, but you can
override the default by setting the `AWS_METADATA_TIMEOUT_MILLISECONDS` variable.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of updating this to:

The default deadline for the EC2 metadata API endpoint is 100 milliseconds, which can be overidden by setting the `AWS_METADATA_TIMEOUT_MILLISECONDS` environment variable.

?

@Ninir Ninir added the feature label Jun 23, 2017
@handlerbot
Copy link
Contributor Author

@Ninir Thanks for the quick review, and the thoughtful feedback! Everything's addressed and ready for next review.

@radeksimko
Copy link
Member

I'm 👌 with the idea overall and leave the final review on @Ninir

Just one question from me here - is it worth accepting the standard duration format, e.g. 1m, 20sec, 100ms etc? I'm aware it would probably change a bunch of things in the code, e.g. AWS_METADATA_TIMEOUT_MILLISECONDS to AWS_METADATA_TIMEOUT and the parsing logic to time.ParseDuration and I don't want to cause much pain, but I also feel it's worth considering. 😉

btw. by convention we always leave the Changelog outside of PRs as it's responsibility of the person merging the PR. We can avoid unnecessary conflicts that way.

@radeksimko radeksimko added enhancement Requests to existing resources that expand the functionality or scope. and removed feature labels Jun 25, 2017
@Ninir
Copy link
Contributor

Ninir commented Jun 26, 2017

Hey @handlerbot

Could you estimate the work to make regarding @radeksimko 's proposal?
If it's too much for this work, this could be done in another PR.

Thanks!

@handlerbot
Copy link
Contributor Author

@Ninir @radeksimko Redone to use time.Duration, and I removed my Changelog commit.

@handlerbot handlerbot changed the title AWS_METADATA_TIMEOUT_MILLISECONDS configuration variable AWS_METADATA_TIMEOUT configuration variable Jun 27, 2017
@handlerbot handlerbot changed the title AWS_METADATA_TIMEOUT configuration variable AWS_METADATA_TIMEOUT configuration environment variable Jun 27, 2017
@handlerbot
Copy link
Contributor Author

Apologies for nudging, but anything else needed from me on this side? Would love to get this in before Terraform 0.10 hits, though I have no idea when that will be. :-)

Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

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

Hey @handlerbot

This seems all good to me :)
This will probably be in the 0.10, even though there will be multiple betas until the final version :)

Thanks for the work here!

@Ninir Ninir merged commit f49bd2f into hashicorp:master Jun 29, 2017
@handlerbot handlerbot deleted the metadata-timeout branch June 29, 2017 10:21
@ghost
Copy link

ghost commented Apr 12, 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 Apr 12, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants