Skip to content

Commit 3150c52

Browse files
author
Andrew Farries
committed
[webapp] Introduce new instance phase "building" (part I, back- and forwards-compatible)
1 parent 926e792 commit 3150c52

File tree

9 files changed

+35
-16
lines changed

9 files changed

+35
-16
lines changed

components/dashboard/src/components/PrebuildLogs.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ export default function PrebuildLogs(props: PrebuildLogsProps) {
8282
useEffect(() => {
8383
switch (workspaceInstance?.status.phase) {
8484
// Preparing means that we haven't actually started the workspace instance just yet, but rather
85-
// are still preparing for launch. This means we're building the Docker image for the workspace.
85+
// are still preparing for launch.
8686
case "preparing":
87+
// Building means we're building the Docker image for the workspace so the workspace hasn't started yet.
88+
case "building":
8789
case "stopped":
8890
getGitpodService().server.watchWorkspaceImageBuildLogs(workspace!.id);
8991
break;

components/dashboard/src/start/StartWorkspace.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
340340
return;
341341
}
342342

343-
if (workspaceInstance.status.phase === "preparing") {
343+
if (workspaceInstance.status.phase === "building" || workspaceInstance.status.phase == "preparing") {
344344
this.setState({ hasImageBuildLogs: true });
345345
}
346346

@@ -402,10 +402,11 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
402402
// a workspace. This phase is usually accompanied by an error.
403403
case "unknown":
404404
break;
405-
406405
// Preparing means that we haven't actually started the workspace instance just yet, but rather
407-
// are still preparing for launch. This means we're building the Docker image for the workspace.
406+
// are still preparing for launch.
408407
case "preparing":
408+
// Building means we're building the Docker image for the workspace.
409+
case "building":
409410
return <ImageBuildView workspaceId={this.state.workspaceInstance.workspaceId} />;
410411

411412
// Pending means the workspace does not yet consume resources in the cluster, but rather is looking for

components/gitpod-protocol/src/gitpod-service.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,14 @@ const hasWindow = typeof window !== "undefined";
530530
const phasesOrder: Record<WorkspaceInstancePhase, number> = {
531531
unknown: 0,
532532
preparing: 1,
533-
pending: 2,
534-
creating: 3,
535-
initializing: 4,
536-
running: 5,
537-
interrupted: 6,
538-
stopping: 7,
539-
stopped: 8,
533+
building: 2,
534+
pending: 3,
535+
creating: 4,
536+
initializing: 5,
537+
running: 6,
538+
interrupted: 7,
539+
stopping: 8,
540+
stopped: 9,
540541
};
541542
export class WorkspaceInstanceUpdateListener {
542543
private readonly onDidChangeEmitter = new Emitter<void>();

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@ export type WorkspaceInstancePhase =
9898
| "unknown"
9999

100100
// Preparing means that we haven't actually started the workspace instance just yet, but rather
101-
// are still preparing for launch. This means we're building the Docker image for the workspace.
101+
// are still preparing for launch.
102102
| "preparing"
103103

104+
// Building means that we are building the Docker image for the workspace. A workspace will enter this phase only
105+
// if an image build is required for that workspace.
106+
| "building"
107+
104108
// Pending means the workspace does not yet consume resources in the cluster, but rather is looking for
105109
// some space within the cluster. If for example the cluster needs to scale up to accomodate the
106110
// workspace, the workspace will be in Pending state until that happened.

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodConnectionProvider.kt

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ class GitpodConnectionProvider : GatewayConnectionProvider {
164164
when (update.status.phase) {
165165
"preparing" -> {
166166
phaseMessage.text = "Preparing"
167+
statusMessage.text = "Preparing workspace..."
168+
}
169+
"building" -> {
170+
phaseMessage.text = "Building"
167171
statusMessage.text = "Building workspace image..."
168172
}
169173
"pending" -> {

components/server/src/workspace/gitpod-server-impl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1541,8 +1541,8 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
15411541
await new Promise((resolve) => setTimeout(resolve, 2000));
15421542

15431543
const wsi = await this.workspaceDb.trace(ctx).findInstanceById(instance.id);
1544-
if (!wsi || wsi.status.phase !== "preparing") {
1545-
log.debug(logCtx, `imagebuild logs: instance is not/no longer in 'preparing' state`, {
1544+
if (!wsi || (wsi.status.phase !== "preparing" && wsi.status.phase !== "building")) {
1545+
log.debug(logCtx, `imagebuild logs: instance is not/no longer in 'building' state`, {
15461546
phase: wsi?.status.phase,
15471547
});
15481548
return;

components/server/src/workspace/headless-log-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ export class HeadlessLogService {
416416
function isSupervisorAvailableSoon(wsi: WorkspaceInstance): boolean {
417417
switch (wsi.status.phase) {
418418
case "creating":
419+
case "building":
419420
case "preparing":
420421
case "initializing":
421422
case "pending":

components/ws-manager-bridge/src/bridge.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class WorkspaceManagerBridge implements Disposable {
106106
// Still, listen to all updates, generate/derive new state and distribute it locally!
107107
startStatusUpdateHandler(false);
108108

109-
// emulate WorkspaceInstance updates for all Workspaces in the "preparing" phase in this cluster
109+
// emulate WorkspaceInstance updates for all Workspaces in the "preparing" or "building" phase in this cluster
110110
const updateEmulator = this.preparingUpdateEmulatorFactory() as PreparingUpdateEmulator;
111111
this.disposables.push(updateEmulator);
112112
updateEmulator.start(cluster.name);

components/ws-manager-bridge/src/preparing-update-emulator.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export class PreparingUpdateEmulator implements Disposable {
4242
const span = TraceContext.startSpan("preparingUpdateEmulatorRun");
4343
const ctx = { span };
4444
try {
45-
const instances = await this.workspaceDb.findInstancesByPhaseAndRegion("preparing", region);
45+
const instances = (
46+
await Promise.all([
47+
this.workspaceDb.findInstancesByPhaseAndRegion("preparing", region),
48+
this.workspaceDb.findInstancesByPhaseAndRegion("building", region),
49+
])
50+
).flat();
51+
4652
span.setTag("preparingUpdateEmulatorRun.nrOfInstances", instances.length);
4753
for (const instance of instances) {
4854
const hash = hasher(instance);

0 commit comments

Comments
 (0)