-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[server] migrate ws without usageattribution #17485
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
Conversation
// we need to update old workspaces on the fly that didn't get an orgId because we lack attribution on their instances. | ||
// this can be removed eventually. | ||
if (user.additionalData?.isMigratedToTeamOnlyAttribution) { | ||
try { |
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.
this runs the same tested code, but just to be sure is wrapped in try-catch.
async updateWorkspacesOrganizationId(workspaces: WorkspaceInfo[], userOrgId: string): Promise<WorkspaceInfo[]> { | ||
return await Promise.all( | ||
workspaces.map(async (ws) => { | ||
if (!ws.workspace.organizationId) { |
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.
It only doies something on workspaces without an organizationId. So should be fast in other cases.
@@ -158,4 +158,41 @@ describe("Migration Service", () => { | |||
const teams = await teamDB.findTeamsByUser(user.id); | |||
expect(teams[0].name).to.be.eq("X Organization"); | |||
}); | |||
|
|||
it("should update 'organizationId' for workspace without attributionId", async () => { |
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.
This test fails without the addition in the migration code
throw new ResponseError(ErrorCodes.NOT_FOUND, "Workspace not found."); | ||
} | ||
return ws; | ||
if (!workspace.organizationId && this.user?.additionalData?.isMigratedToTeamOnlyAttribution) { | ||
try { |
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.
try-catch here as well. Also only runs for workspaces without orgId and after migration
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 for the test
/unhold |
log.info({ userId: this.user.id }, "Updating workspace without orgId."); | ||
const userOrg = await this.userToTeamMigrationService.getUserOrganization(this.user); | ||
const latestInstance = await this.workspaceDb.trace({}).findCurrentInstance(workspace.id); | ||
this.userToTeamMigrationService.updateWorkspacesOrganizationId( |
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.
Missing await
? Or is this supposed to be not awaited on?
#17489 to fix the build
Description
In the migration we didn't anticipate that we have only updated usageAttribuitionIds for workspace instances from last June until now.
This change makes sure that workspaces get an orgId oin migration and because we already have executed many migrations we unfortunately also need to fix this on the fly.
Related Issue(s)
Fixes #17482
Fixes WEB-294
How to test
Documentation
Preview status
gitpod:summary
Build Options:
Run the build with werft instead of GHA
Run Leeway with
--dont-test
Publish Options
Installer Options
Add desired feature flags to the end of the line above, space separated
Preview Environment Options:
If enabled this will build
install/preview
If enabled this will create the environment on GCE infra
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh
/hold