diff --git a/components/dashboard/src/components/PrebuildLogs.tsx b/components/dashboard/src/components/PrebuildLogs.tsx index bb8d9878760aa4..31f3bee9a0d2c2 100644 --- a/components/dashboard/src/components/PrebuildLogs.tsx +++ b/components/dashboard/src/components/PrebuildLogs.tsx @@ -7,7 +7,6 @@ import EventEmitter from "events"; import React, { Suspense, useEffect, useState } from "react"; import { - Workspace, WorkspaceInstance, DisposableCollection, WorkspaceImageBuild, @@ -23,7 +22,6 @@ export interface PrebuildLogsProps { } export default function PrebuildLogs(props: PrebuildLogsProps) { - const [workspace, setWorkspace] = useState(); const [workspaceInstance, setWorkspaceInstance] = useState(); const [error, setError] = useState(); const [logsEmitter] = useState(new EventEmitter()); @@ -38,9 +36,11 @@ export default function PrebuildLogs(props: PrebuildLogsProps) { try { const info = await getGitpodService().server.getWorkspace(props.workspaceId); if (info.latestInstance) { - setWorkspace(info.workspace); setWorkspaceInstance(info.latestInstance); } + + await getGitpodService().server.watchWorkspaceImageBuildLogs(props.workspaceId); + disposables.push( getGitpodService().registerClient({ onInstanceUpdate: (instance) => { @@ -84,60 +84,6 @@ export default function PrebuildLogs(props: PrebuildLogsProps) { if (props.onInstanceUpdate && workspaceInstance) { props.onInstanceUpdate(workspaceInstance); } - switch (workspaceInstance?.status.phase) { - // unknown indicates an issue within the system in that it cannot determine the actual phase of - // a workspace. This phase is usually accompanied by an error. - case "unknown": - break; - - // Preparing means that we haven't actually started the workspace instance just yet, but rather - // are still preparing for launch. This means we're building the Docker image for the workspace. - case "preparing": - getGitpodService().server.watchWorkspaceImageBuildLogs(workspace!.id); - break; - - // Pending means the workspace does not yet consume resources in the cluster, but rather is looking for - // some space within the cluster. If for example the cluster needs to scale up to accomodate the - // workspace, the workspace will be in Pending state until that happened. - case "pending": - break; - - // Creating means the workspace is currently being created. That includes downloading the images required - // to run the workspace over the network. The time spent in this phase varies widely and depends on the current - // network speed, image size and cache states. - case "creating": - break; - - // Initializing is the phase in which the workspace is executing the appropriate workspace initializer (e.g. Git - // clone or backup download). After this phase one can expect the workspace to either be Running or Failed. - case "initializing": - break; - - // Running means the workspace is able to actively perform work, either by serving a user through Theia, - // or as a headless workspace. - case "running": - break; - - // Interrupted is an exceptional state where the container should be running but is temporarily unavailable. - // When in this state, we expect it to become running or stopping anytime soon. - case "interrupted": - break; - - // Stopping means that the workspace is currently shutting down. It could go to stopped every moment. - case "stopping": - break; - - // Stopped means the workspace ended regularly because it was shut down. - case "stopped": - getGitpodService().server.watchWorkspaceImageBuildLogs(workspace!.id); - break; - } - if (workspaceInstance?.status.conditions.headlessTaskFailed) { - setError(new Error(workspaceInstance.status.conditions.headlessTaskFailed)); - } - if (workspaceInstance?.status.conditions.failed) { - setError(new Error(workspaceInstance.status.conditions.failed)); - } }, [props.workspaceId, workspaceInstance?.status.phase]); return (