-
Notifications
You must be signed in to change notification settings - Fork 229
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
feat: Modify the refresh window to match go/async-token-refresh. Serverless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window. #1352
Conversation
…erless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window.
@@ -68,7 +68,7 @@ | |||
public class OAuth2Credentials extends Credentials { | |||
|
|||
private static final long serialVersionUID = 4556936364828217687L; | |||
static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(5); | |||
static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(3).plusSeconds(45); | |||
static final Duration DEFAULT_REFRESH_MARGIN = Duration.ofMinutes(6); |
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.
I think you want to change both? This to 4 mins or slightly below and expiration to below 3min.
Right now it will start refreshing at 6 mins and get insta cached response for next 2 mins.
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.
Left comment on changing both values
Good point. I have revised the change |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
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.
LGTM, thanks!
@clundin25 Hey sorry for the late comment... but it looks like those margins aren't covered with tests, could you please add those? There are margin related tests in ComputeCredentialTests |
@TimurSadykov It seems that it is currently just testing the getters. Is there an additional test you had in mind https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/javatests/com/google/auth/oauth2/ComputeEngineCredentialsTest.java#L200-L205? |
@clundin25 it is a bit more than a getter validation. The test you highlighted validates that compute credentials has their specific margins set. As i understand similar tests are missing for other credentials that supposed to use defaults. It could be that custom margins set up for some credentials and its a bug. |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> ☕️
If you write sample code, please follow the samples format.