Skip to content

Commit 86fa3ba

Browse files
authored
[server] Separate instance creation from instance starting (again) (#18642)
* [server] Separate instance creation from instance starting (again) * [server] Set instance.configuration.fromBackup
1 parent d4c66fd commit 86fa3ba

File tree

5 files changed

+125
-126
lines changed

5 files changed

+125
-126
lines changed

components/gitpod-db/src/typeorm/entity/db-workspace-instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class DBWorkspaceInstance implements WorkspaceInstance {
101101
type: "simple-json",
102102
nullable: true,
103103
})
104-
configuration?: WorkspaceInstanceConfiguration;
104+
configuration: WorkspaceInstanceConfiguration;
105105

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

components/gitpod-protocol/src/workspace-instance.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { NamedWorkspaceFeatureFlag } from "./protocol";
7+
import { EnvVar, NamedWorkspaceFeatureFlag, TaskConfig } from "./protocol";
8+
import { WorkspaceRegion } from "./workspace-cluster";
89

910
// WorkspaceInstance describes a part of a workspace's lifetime, specifically a single running session of it
1011
export interface WorkspaceInstance {
@@ -30,15 +31,15 @@ export interface WorkspaceInstance {
3031
stoppedTime?: string;
3132

3233
// ideUrl is the URL at which the workspace is available on the internet
33-
// Note: this is nitially empty, filled during starting process!
34+
// Note: this is initially empty, filled during starting process!
3435
ideUrl: string;
3536

3637
// region is the name of the workspace cluster this instance runs in
37-
// Note: this is nitially empty, filled during starting process!
38+
// Note: this is initially empty, filled during starting process!
3839
region: string;
3940

4041
// workspaceImage is the name of the Docker image this instance runs
41-
// Note: this is nitially empty, filled during starting process!
42+
// Note: this is initially empty, filled during starting process!
4243
workspaceImage: string;
4344

4445
// status is the latest status of the instance that we're aware of
@@ -48,9 +49,7 @@ export interface WorkspaceInstance {
4849
gitStatus?: WorkspaceInstanceRepoStatus;
4950

5051
// configuration captures the per-instance configuration variance of a workspace
51-
// Beware: this field was added retroactively and not all instances have valid
52-
// values here.
53-
configuration?: WorkspaceInstanceConfiguration;
52+
configuration: WorkspaceInstanceConfiguration;
5453

5554
// instance is hard-deleted on the database and about to be collected by periodic deleter
5655
readonly deleted?: boolean;
@@ -280,6 +279,11 @@ export interface ConfigurationIdeConfig {
280279
ide?: string;
281280
}
282281

282+
export interface IdeSetup {
283+
tasks?: TaskConfig[];
284+
envvars?: EnvVar[];
285+
}
286+
283287
// WorkspaceInstanceConfiguration contains all per-instance configuration
284288
export interface WorkspaceInstanceConfiguration {
285289
// theiaVersion is the version of Theia this workspace instance uses
@@ -296,18 +300,21 @@ export interface WorkspaceInstanceConfiguration {
296300
// including ide-desktop, desktop-plugin and so on
297301
ideImageLayers?: string[];
298302

299-
// desktopIdeImage is the ref of the desktop IDE image this instance uses.
300-
// @deprected: replaced with the ideImageLayers field
301-
desktopIdeImage?: string;
302-
303-
// desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
304-
// @deprected: replaced with the desktopIdePluginImage field
305-
desktopIdePluginImage?: string;
306-
307303
// supervisorImage is the ref of the supervisor image this instance uses.
308304
supervisorImage?: string;
309305

306+
// ideSetup contains all piece that are necessary to get the IDE running
307+
// TODO(gpl) ideally also contains the fields above: ideImage, ideImageLayers and supervisorImage
308+
ideSetup?: IdeSetup;
309+
310+
// ideConfig contains user-controlled IDE configuration
310311
ideConfig?: ConfigurationIdeConfig;
312+
313+
// The region the user passed as a preference for this workspace
314+
regionPreference?: WorkspaceRegion;
315+
316+
// Whether this instance is started from a backup
317+
fromBackup?: boolean;
311318
}
312319

313320
/**

components/server/src/auth/resource-access.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ class TestResourceAccess {
706706
workspaceId,
707707
creationTime: new Date(2000, 1, 2).toISOString(),
708708
region: "local",
709+
configuration: {
710+
ideImage: "gitpod/workspace-full:latest",
711+
},
709712
status: {
710713
version: 1,
711714
conditions: {},

components/server/src/ide-service.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See License.AGPL.txt in the project root for license information.
55
*/
66

7-
import { IDESettings, TaskConfig, User, Workspace } from "@gitpod/gitpod-protocol";
7+
import { IDESettings, User, Workspace } from "@gitpod/gitpod-protocol";
88
import { IDEClient, IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol";
99
import * as IdeServiceApi from "@gitpod/ide-service-api/lib/ide.pb";
1010
import {
@@ -102,20 +102,4 @@ export class IDEService {
102102
}
103103
throw new Error("failed to resolve workspace IDE configuration");
104104
}
105-
106-
resolveGitpodTasks(ws: Workspace, ideConfig: ResolveWorkspaceConfigResponse): TaskConfig[] {
107-
const tasks: TaskConfig[] = [];
108-
if (ws.config.tasks) {
109-
tasks.push(...ws.config.tasks);
110-
}
111-
if (ideConfig.tasks) {
112-
try {
113-
const ideTasks: TaskConfig[] = JSON.parse(ideConfig.tasks);
114-
tasks.push(...ideTasks);
115-
} catch (e) {
116-
console.error("failed get tasks from ide config:", e);
117-
}
118-
}
119-
return tasks;
120-
}
121105
}

0 commit comments

Comments
 (0)