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

Fix concurrent token renewal issues #10794

Merged
merged 2 commits into from
Jun 24, 2022
Merged

Fix concurrent token renewal issues #10794

merged 2 commits into from
Jun 24, 2022

Conversation

AlexTugarev
Copy link
Member

Description

Related Issue(s)

Fixes #10762

How to test

  1. Use git with the gitlab.com integration for a while, no issues with tokens should occur.

Release Notes

Token renewals should not run concurrently.

Documentation

Werft options:

  • /werft with-preview

@AlexTugarev AlexTugarev requested a review from a team June 21, 2022 09:43
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Jun 21, 2022
Copy link
Contributor

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

How does this work between multiple server replicas? This promise cache is per-server - does that matter?

/hold

Comment on lines +55 to +57
const aboutToExpireTime = new Date();
aboutToExpireTime.setTime(aboutToExpireTime.getTime() + 5 * 60 * 1000);
if (token.expiryDate && token.expiryDate < aboutToExpireTime.toISOString()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this renamed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Renaming was not necessary, but that reflect the purpose of this time, while refreshTime does not.

Also note the change from 30 to 5 minutes before expiration.

@AlexTugarev
Copy link
Member Author

How does this work between multiple server replicas? This promise cache is per-server - does that matter?

@andrew-farries, that's a good question. The greatest problem to be solved with this PR actually occurs on a single server pod, which maintains a websocket, where a client is connected to. There are cases where a single user action (e.g. create workspace request) is triggering a bunch of API requests, which are made in parallel for a better performance, e.g. https://github.com/gitpod-io/gitpod/blob/main/components/server/src/gitlab/file-provider.ts#L19-L22.

@AlexTugarev
Copy link
Member Author

/hold cancel

@roboquat roboquat merged commit 9a9c01e into main Jun 24, 2022
@roboquat roboquat deleted the at/token-renewal branch June 24, 2022 05:49
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note size/S team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't refresh tokens twice in parallel
3 participants