-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
EC2MetadataCredentials and ECSCredentials retry #1114
Conversation
…Credentials. Adds queuing of refresh callbacks to ECSCredentials to reduce the number of asynchronous requests to retrieve credentials.
2 similar comments
@@ -100,7 +100,7 @@ require('./credentials/credential_provider_chain'); | |||
* Currently supported options are: | |||
* | |||
* * **base** [Integer] — The base number of milliseconds to use in the | |||
* exponential backoff for operation retries. Defaults to 100 ms. | |||
* exponential backoff for operation retries. Defaults to 30 ms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default used to be 30 ms but was changed to 100 ms with the configurable retry delays.
…es retry delay util function to use default 100ms base retry delay.
2 similar comments
}, | ||
|
||
/** | ||
* @api private | ||
*/ | ||
refreshQueue: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the refresh queue only implemented for ECS credentials and not EC2 credentials? EC2 credentials has the same issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EC2MetdataCredentials already had this feature, through the MetadataService. The refreshQueue
on the ECSCredentials is analogous to the loadCredentialsCallbacks
on the MetadataService. They're structured slightly differently but work the same way. (refreshQueue
has to retain references to the instances of ECSCredentials because the data isn't given to the callback the way it is in MetadataService).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so EC2 already supported this, excellent.
…des and retry-after headers
if (statusCode < 300) { | ||
cb(null, data); | ||
} else { | ||
var retryAfter = parseInt(httpResponse.headers['retry-after']) * 1000 || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing, but might want to specify that the int is a decimal number when parsing parseInt(str, 10)
for a little extra safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll modify it.
1 similar comment
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Adds retry to sourcing credentials for IAM Roles in the EC2 Metadata Service or in ECS. By default will retry up to 3 times, with exponential backoff. Also for ECSCredentials, this PR will allow one asynchronous request to serve multiple refresh calls, so that at most only one request will be in flight at any point. Resolves #692
/cc: @chrisradek