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

Add stale time config to InstanceProfileCredentialsProvider #5758

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

L-Applin
Copy link
Contributor

Add stale time config to InstanceProfileCredentialsProvider to allow for refreshing credentials earlier due to stale value. This will help prevent returning invalid credentials when an error is encountered during asynchronous refresh.

Motivation and Context

Fixes for #5247 , this will allow user to provide a higher value for prefetch to prevent returning expired credentails without changing default value. Increasing this value may lead to a higher rate of request to IMDS, so we ought to avoid changing the base default value for it.

Modifications

  • Added the staleTime configuration option to InstanceProfileCredentialsProvider
  • Added retry strategy for InstanceProfileCredentialsProvider

Testing

Added unit tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

…for refreshing credentials earlier due to stale value. This will help prevent returning invalid credentials when an error is encountered during asynchronous refresh.
@L-Applin L-Applin requested a review from a team as a code owner December 18, 2024 17:14
…for refreshing credentials earlier due to stale value. This will help prevent returning invalid credentials when an error is encountered during asynchronous refresh.
Copy link

@steveloughran steveloughran left a comment

Choose a reason for hiding this comment

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

you need to change that default to be > 10s; without that any 503 response is not going be recovered from.

Those of us who have encountered the problem will know to explicitly change it, but people who haven't yet hit it will only find out when things go wrong.

There is also the subtlety that all processes running in the same VM will be using the same timeout, as it is based on when the shared credentials expire. The more processes running, the more risk of that 503 -regardless of what the value is. This means that any constant value can create a Thundering Herd.

The "extra load" concern is marginal, given refresh time is every hour. spreading out that load is likely to be better as any herd-triggered retry is load in itself.

I'd suggest some larger number and maybe a jitter of a few seconds to spread out load from many processes.

@L-Applin
Copy link
Contributor Author

L-Applin commented Jan 6, 2025

you need to change that default to be > 10s; without that any 503 response is not going be recovered from.

Those of us who have encountered the problem will know to explicitly change it, but people who haven't yet hit it will only find out when things go wrong.

There is also the subtlety that all processes running in the same VM will be using the same timeout, as it is based on when the shared credentials expire. The more processes running, the more risk of that 503 -regardless of what the value is. This means that any constant value can create a Thundering Herd.

The "extra load" concern is marginal, given refresh time is every hour. spreading out that load is likely to be better as any herd-triggered retry is load in itself.

I'd suggest some larger number and maybe a jitter of a few seconds to spread out load from many processes.

There is already jitter, up to 1 minute before expiration time. Also, I am weary of changing default values, it may cause unexpected behaviour change in user applications and we try to avoid those. Is the ability to configure the value manually on the builder yourself not a viable solution for your use case?

@steveloughran
Copy link

I'm happy with the change -but do think you should consider documenting this for others

@L-Applin
Copy link
Contributor Author

L-Applin commented Jan 7, 2025

I'm happy with the change -but do think you should consider documenting this for others

Good point, I added a note about the issue in the javadoc for staleTime

Copy link

sonarqubecloud bot commented Jan 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
73.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants