Skip to content

[server] Separate instance creation from instance starting (again) #18642

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 2 commits into from
Sep 4, 2023
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 @@ -101,7 +101,7 @@ export class DBWorkspaceInstance implements WorkspaceInstance {
type: "simple-json",
nullable: true,
})
configuration?: WorkspaceInstanceConfiguration;
configuration: WorkspaceInstanceConfiguration;
Copy link
Member Author

Choose a reason for hiding this comment

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

I checked the DB: We have 0 instances where this field is NULL or "".


@Column("simple-json", { nullable: true })
imageBuildInfo?: ImageBuildInfo;
Expand Down
37 changes: 22 additions & 15 deletions components/gitpod-protocol/src/workspace-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* See License.AGPL.txt in the project root for license information.
*/

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

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

// ideUrl is the URL at which the workspace is available on the internet
// Note: this is nitially empty, filled during starting process!
// Note: this is initially empty, filled during starting process!
ideUrl: string;

// region is the name of the workspace cluster this instance runs in
// Note: this is nitially empty, filled during starting process!
// Note: this is initially empty, filled during starting process!
region: string;

// workspaceImage is the name of the Docker image this instance runs
// Note: this is nitially empty, filled during starting process!
// Note: this is initially empty, filled during starting process!
workspaceImage: string;

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

// configuration captures the per-instance configuration variance of a workspace
// Beware: this field was added retroactively and not all instances have valid
// values here.
configuration?: WorkspaceInstanceConfiguration;
configuration: WorkspaceInstanceConfiguration;
Copy link
Member Author

Choose a reason for hiding this comment

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

I checked the DB: We have 0 instances where this field is NULL or "".


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

export interface IdeSetup {
tasks?: TaskConfig[];
envvars?: EnvVar[];
}

// WorkspaceInstanceConfiguration contains all per-instance configuration
export interface WorkspaceInstanceConfiguration {
// theiaVersion is the version of Theia this workspace instance uses
Expand All @@ -296,18 +300,21 @@ export interface WorkspaceInstanceConfiguration {
// including ide-desktop, desktop-plugin and so on
ideImageLayers?: string[];

// desktopIdeImage is the ref of the desktop IDE image this instance uses.
// @deprected: replaced with the ideImageLayers field
desktopIdeImage?: string;

// desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
// @deprected: replaced with the desktopIdePluginImage field
desktopIdePluginImage?: string;

// supervisorImage is the ref of the supervisor image this instance uses.
supervisorImage?: string;

// ideSetup contains all piece that are necessary to get the IDE running
// TODO(gpl) ideally also contains the fields above: ideImage, ideImageLayers and supervisorImage
ideSetup?: IdeSetup;

// ideConfig contains user-controlled IDE configuration
ideConfig?: ConfigurationIdeConfig;

// The region the user passed as a preference for this workspace
regionPreference?: WorkspaceRegion;

// Whether this instance is started from a backup
fromBackup?: boolean;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions components/server/src/auth/resource-access.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ class TestResourceAccess {
workspaceId,
creationTime: new Date(2000, 1, 2).toISOString(),
region: "local",
configuration: {
ideImage: "gitpod/workspace-full:latest",
},
status: {
version: 1,
conditions: {},
Expand Down
18 changes: 1 addition & 17 deletions components/server/src/ide-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import { IDESettings, TaskConfig, User, Workspace } from "@gitpod/gitpod-protocol";
import { IDESettings, User, Workspace } from "@gitpod/gitpod-protocol";
import { IDEClient, IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol";
import * as IdeServiceApi from "@gitpod/ide-service-api/lib/ide.pb";
import {
Expand Down Expand Up @@ -102,20 +102,4 @@ export class IDEService {
}
throw new Error("failed to resolve workspace IDE configuration");
}

resolveGitpodTasks(ws: Workspace, ideConfig: ResolveWorkspaceConfigResponse): TaskConfig[] {
const tasks: TaskConfig[] = [];
if (ws.config.tasks) {
tasks.push(...ws.config.tasks);
}
if (ideConfig.tasks) {
try {
const ideTasks: TaskConfig[] = JSON.parse(ideConfig.tasks);
tasks.push(...ideTasks);
} catch (e) {
console.error("failed get tasks from ide config:", e);
}
}
return tasks;
}
}
Loading