-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add workspace class to workspace instance #10454
Conversation
components/gitpod-db/src/typeorm/entity/db-workspace-instance.ts
Outdated
Show resolved
Hide resolved
@@ -501,6 +501,7 @@ export class WorkspaceStarter { | |||
|
|||
instance.status.phase = "pending"; | |||
instance.region = installation; | |||
instance.workspaceClass = startRequest.getSpec()!.getClass(); |
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.
👍
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.
Hey, many thanks for implementing this @atduarte! 🎉
Regarding how this can be tested, I'd suggest the following:
- Add
- [x] /werft with-payment
at the bottom of your PR description, and trigger a new Werft build (this will enable paid plans) - Set up a Chargebee webhook for this PR (I can do that for you)
- Connect to the database like so:
- Open the PR in Gitpod
- Run
./dev/preview/install-k3s-kubeconfig.sh
(manually 🙄) - Run
kubectl port-forward mysql-0 3306 &
(to expose the database port) - Run
mysql -h 127.0.0.1 -pjBzVMe2w4Yi7GagadsyB gitpod
(to connect to the database)
Next, you'll be able to test this:
- Start a new workspace while on the free plan
- in the database, the workspace instance should have
workspaceClass: 'default'
- in the database, the workspace instance should have
- Grant yourself access to XL:
- create a new team (e.g. by visiting
/teams/new
) - upgrade the team to Unleashed (in team settings > billing)
- in the database, update
d_b_team_subscription2
excludeFromMoreResources
to0
- create a new team (e.g. by visiting
- Start the same workspace again, or a new workspace
- this workspace should have
workspaceClass = 'gitpodio-internal-xl'
in the DB
- this workspace should have
Happy to help with any of this, and/or have a call. 😁
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.
Thanks for the thoughtful comments and guidance, @jankeromnes! 🧡
I'm currently stuck at "upgrade the team to Unleashed (in team settings > billing)" as I'm required to pay. 🤔 Looked for ways on Slack and Notion without any luck. Got it 🔍
"Payment in Progress". I guess you need to activate the Chargebee webhook now?
components/gitpod-db/src/typeorm/entity/db-workspace-instance.ts
Outdated
Show resolved
Hide resolved
Sure, more than happy to help, especially since you spontaneously started implementing this yourself. 💯 Many thanks for that.
Ah, yes indeed, forgot to set this up. I went into Chargebee and added a webhook for this PR, so payments should go through now. (Also, didn't share the exact steps, because we're considering moving away from Chargebee soon, but if you're curious I'm still happy to share more anyway)
Hmm, that's a good point. I still think we'll need some kind of fixed mapping between particular classes and credits/prices, but maybe that could also be dynamic? Since this is still a bit unclear and somewhat orthogonal to this contribution, I have no strong feelings about enum or not -- please feel free to go ahead with whatever is most convenient for this PR, and let's figure out the mapping in a future iteration. 👍 |
/werft with-payment |
/werft run with-payment 👍 started the job as gitpod-build-ad-workspace-class.3 |
LGTM. I've 2 questions remaining:
|
1 similar comment
LGTM. I've 2 questions remaining:
|
From my point of view: yes, absolutely. I imagine a extreme case where you start up a workspace in the past, and try to re-start after 1 month. However the config change, the new instance should be guided by that, and not what was configured in the past. |
@easyCZ The class is chosen by the server and currently is actually hard-coded here: gitpod/components/server/src/workspace/workspace-starter.ts Lines 1298 to 1301 in 6a80342
|
public async up(queryRunner: QueryRunner): Promise<void> { | ||
if (!(await columnExists(queryRunner, TABLE_NAME, COLUMN_NAME))) { | ||
await queryRunner.query( | ||
`ALTER TABLE ${TABLE_NAME} ADD COLUMN ${COLUMN_NAME} varchar(255) NOT NULL DEFAULT '', ALGORITHM=INPLACE, LOCK=NONE`, |
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.
🔥 Thanks for adding the ALGORITHM=INPLACE, LOCK=NONE
here, which will avoid about 2 hours of db-sync
downtime during deployment. 😁 🚀
Description
Adds the workspace class, also known as workspace size, to the workspace instance. This will be relevant to determine usage costs and for our own reporting.
A workspace class determines what type of resources a given workspace instance gets.
Related Issue(s)
Fixes #10430
How to test
Manual test using preview environments, using @jankeromnes suggested steps.
Results
Release Notes
Documentation