-
Notifications
You must be signed in to change notification settings - Fork 11.4k
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: Implement Cloud communication reliability #31986
Conversation
Done so we can access anywhere how we structure our workspace credentials
🦋 Changeset detectedLatest commit: 97ec7cb The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #31986 +/- ##
===========================================
+ Coverage 55.48% 55.64% +0.16%
===========================================
Files 2371 2426 +55
Lines 52062 53356 +1294
Branches 10651 10970 +319
===========================================
+ Hits 28888 29692 +804
- Misses 20636 21037 +401
- Partials 2538 2627 +89
Flags with carried forward coverage won't be shown. Click here to find out more. |
I think I should write a migration to move the |
I think client id and client secret should stay in settings and use the settings get that bypasses cache. Making the new collection only for access tokens Actually every thing but workspace access token and its expire, and scopes should stay. imo the fields on the new collection should be: _id, scopes, expire, access_token Then for speed the index could contain all values so it only ever hits mongo index and never needs to hit disk |
Oooh, it makes a lot of sense now, will work on it now, thx |
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Is possible to add some tests here? |
Co-authored-by: Matheus Barbosa Silva <[email protected]>
@AllanPazRibeiro I guess we should find a way to add tests for our cloud services, but I am not sure if it is possible now, do you have any idea on how could we do it? |
Maybe you could add an e2e test for this endpoint apps/meteor/ee/server/apps/communication/rest.ts |
Proposed changes (including videos or screenshots)
When a Workspace Registers with Cloud it gets a set of credentials it uses to generate access tokens and communicate with Cloud. Can read more about how this works in ADR3.
When a workspace owner needs to scale and deploys multiple Rocket.Chat instances to make up their deployment. Each workspace establishes a change stream request to mongo watching settings. Then updates its collection cache locally.
When a workspace goes to use an access token to talk to a cloud service it first evaluates if the token needs renewed. If it does it request a new one. Then updates a setting containing the access token. Then also another setting containing the expire.
The problem occures when latency enters the picture. If due to either longer mongo query or network condition the other workspaces don't see both of these changes happen and update its cache. An instance can be using an expired token instead of renewing because the setting cache hasn't been updated.
We've seen many cases of this happen and typically restarting workspace can resolve.
This PR moves all credential related data to the 'workspace_credentials' collection, and stop using settings.get to fetch the configs that can be changed on multiple server instances
Issue(s)
Steps to test or reproduce
Create a new workspace, on registering, it should create a new record inside the
rocketchat_workspace_credentials
collection, containing an empty date asexpirationDate
, an empty string asaccessToken
and an empty string asscopes
.To test everything else, you must use the cloud functions, not sure how to call them from RC, but you could enter the Marketplace screen, go to paid apps, open one of them, and check if there is a new token in the database
Further comments
This implements: https://adr.rocket.chat/0061
CONN-5