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 4 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

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

Comment on lines +63 to +65
public ResourcesEndpointRetryPolicy retryPolicy() {
return new ContainerCredentialsRetryPolicy();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we can add retry at this point for IMDS credentials provider because it may increase latency and break customers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, that was a ask from Hadoop. Instead we can add it as an optional config as well

@@ -174,7 +178,7 @@ private Instant staleTime(Instant expiration) {
return null;
}

return expiration.minusSeconds(1);
return expiration.minus(staleTime);
Copy link
Contributor

Choose a reason for hiding this comment

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

I was trying to understand comment in #3314 (comment)

Looks like the 1 sec is intentional , if a user configures an excessively large stale time (e.g., expiration.minusMinutes(10)), credentials might be marked as stale too early, causing unnecessary refreshes and increased load on the credential provider. WDYT ?

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.

3 participants