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

Add workspace class to workspace instance #10454

Merged
merged 3 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ export class DBWorkspaceInstance implements WorkspaceInstance {

@Column("simple-json", { nullable: true })
imageBuildInfo?: ImageBuildInfo;

@Column({
default: "",
transformer: Transformer.MAP_EMPTY_STR_TO_UNDEFINED,
})
workspaceClass?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
* Licensed under the GNU Affero General Public License (AGPL).
* See License-AGPL.txt in the project root for license information.
*/

import { MigrationInterface, QueryRunner } from "typeorm";
import { columnExists } from "./helper/helper";

const TABLE_NAME = "d_b_workspace_instance";
const COLUMN_NAME = "workspaceClass";

export class WorkspaceClass1654264374619 implements MigrationInterface {
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`,
Copy link
Contributor

@jankeromnes jankeromnes Jun 8, 2022

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. 😁 🚀

);
}
}

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}`);
}
}
}
4 changes: 4 additions & 0 deletions components/gitpod-db/src/workspace-db.spec.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class WorkspaceDBSpec {
id: "123",
ideUrl: "example.org",
region: "unknown",
workspaceClass: undefined,
workspaceImage: "abc.io/test/image:123",
creationTime: this.timeBefore,
startedTime: undefined,
Expand All @@ -70,6 +71,7 @@ class WorkspaceDBSpec {
id: "1234",
ideUrl: "example.org",
region: "unknown",
workspaceClass: undefined,
workspaceImage: "abc.io/test/image:123",
creationTime: this.timeAfter,
startedTime: undefined,
Expand Down Expand Up @@ -106,6 +108,7 @@ class WorkspaceDBSpec {
id: "4",
ideUrl: "example.org",
region: "unknown",
workspaceClass: undefined,
workspaceImage: "abc.io/test/image:123",
creationTime: this.timeBefore,
startedTime: undefined,
Expand Down Expand Up @@ -142,6 +145,7 @@ class WorkspaceDBSpec {
id: "3_1",
ideUrl: "example.org",
region: "unknown",
workspaceClass: undefined,
workspaceImage: "abc.io/test/image:123",
creationTime: this.timeBefore,
startedTime: undefined,
Expand Down
6 changes: 6 additions & 0 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export interface WorkspaceInstance {
* Contains information about the image build, if there was any
*/
imageBuildInfo?: ImageBuildInfo;

/**
* workspace class, also known as workspace size, determines the type of
* resources that are provided to the workspace.
*/
workspaceClass?: string;
}

// WorkspaceInstanceStatus describes the current state of a workspace instance
Expand Down
1 change: 1 addition & 0 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ export class WorkspaceStarter {

instance.status.phase = "pending";
instance.region = installation;
instance.workspaceClass = startRequest.getSpec()!.getClass();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

await this.workspaceDb.trace(ctx).storeInstance(instance);
try {
await this.messageBus.notifyOnInstanceUpdate(workspace.ownerId, instance);
Expand Down