Skip to content

Refactor workspace instance attributedTeamId to an explicit, not-team-specific usageAttributionId #10868

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

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Jun 23, 2022

Description

Refactor workspace instance attributedTeamId to an explicit, not-team-specific usageAttributionId.

Related Issue(s)

Fixes #10822

How to test

  1. Should build
  2. Workspace instances should always get a usageAttributionId
    • If the workspace is for a project that's owned by a Team, the attribution ID should look like team:1234
    • If the workspace is for a user project, or for no project at all, the attribution ID should look like user:1234

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@jankeromnes jankeromnes requested a review from a team June 23, 2022 13:04
@github-actions github-actions bot added team: webapp Issue belongs to the WebApp team and removed size/M labels Jun 23, 2022
@jankeromnes jankeromnes changed the title [gitpod-db][server] Refactor ws instance 'attributedTeamId' to an explicit, not-team-specific 'usageAttributionId' Refactor ws instance attributedTeamId to an explicit, not-team-specific usageAttributionId Jun 23, 2022
@jankeromnes jankeromnes changed the title Refactor ws instance attributedTeamId to an explicit, not-team-specific usageAttributionId Refactor workspace instance attributedTeamId to an explicit, not-team-specific usageAttributionId Jun 23, 2022
@jankeromnes jankeromnes force-pushed the jx/attribution-id branch 2 times, most recently from 7587085 to c3b9026 Compare June 23, 2022 13:14
@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 23, 2022

Bind for 0.0.0.0:23306 failed: port is already allocated

/werft run

👍 started the job as gitpod-build-jx-attribution-id.5
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-jx-attribution-id.7 because the annotations in the pull request description changed
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 23, 2022

It's working! 🎉

mysql> select id, workspaceId, creationTime, usageAttributionId from d_b_workspace_instance;
+--------------------------------------+-----------------------------------+--------------------------+-------------------------------------------+
| id                                   | workspaceId                       | creationTime             | usageAttributionId                        |
+--------------------------------------+-----------------------------------+--------------------------+-------------------------------------------+
| 3610efe0-28f3-43f9-a742-62cf2b15c361 | autofixdev-autofix-qdb4hnp3343    | 2022-06-23T15:01:14.804Z | user:03c5bb79-361d-4956-ad0e-58221b378484 |
| 7e62f39b-8e70-40ea-9fe3-6776e3d51c09 | jankeromnes-metachess-ne9ernqjojg | 2022-06-23T15:02:12.145Z | team:b2ee4f72-2dab-48b9-9b2b-903387e577f2 |
| f63a6dcd-04ca-4ca7-b4ca-d2bdf5ca70af | jankeromnes-metachess-u8zwfhjtiqq | 2022-06-23T15:01:59.035Z | team:b2ee4f72-2dab-48b9-9b2b-903387e577f2 |
+--------------------------------------+-----------------------------------+--------------------------+-------------------------------------------+
3 rows in set (0.01 sec)

public async down(queryRunner: QueryRunner): Promise<void> {
if (await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME)) {
await queryRunner.query(
`ALTER TABLE ${TABLE_NAME} DROP COLUMN ${COLUMN_NAME}, ALGORITHM=INPLACE, LOCK=NONE`,
Copy link
Member

Choose a reason for hiding this comment

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

👍

@geropl geropl self-assigned this Jun 24, 2022
@geropl
Copy link
Member

geropl commented Jun 24, 2022

Nice.
image

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Tested and works, approving to unblock.

/hold So for reducing the column size. 👍

… an explicit, not-team-specific 'usageAttributionId'
@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 24, 2022

@geropl FYI, I've changed the type to varchar(60) and created an index: diff

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 24, 2022

One last sanity check before merging -- running the migration again:

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-jx-attribution-id.9
(with .werft/ from main)

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Jun 24, 2022

Still working as intended! 🎉 Many thanks for the review @geropl 🙏

/unhold

@roboquat roboquat merged commit 59cbf53 into main Jun 24, 2022
@roboquat roboquat deleted the jx/attribution-id branch June 24, 2022 09:08
@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-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Usage-based] Adjust d_b_workspace_instance.attributedTeamId to be not team-specific
3 participants