Skip to content

Commit

Permalink
[dashboard] Remove prebuild status errors from prebuild logs
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed Mar 31, 2022
1 parent 0c3eb89 commit 3966633
Showing 1 changed file with 3 additions and 57 deletions.
60 changes: 3 additions & 57 deletions components/dashboard/src/components/PrebuildLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import EventEmitter from "events";
import React, { Suspense, useEffect, useState } from "react";
import {
Workspace,
WorkspaceInstance,
DisposableCollection,
WorkspaceImageBuild,
Expand All @@ -23,7 +22,6 @@ export interface PrebuildLogsProps {
}

export default function PrebuildLogs(props: PrebuildLogsProps) {
const [workspace, setWorkspace] = useState<Workspace | undefined>();
const [workspaceInstance, setWorkspaceInstance] = useState<WorkspaceInstance | undefined>();
const [error, setError] = useState<Error | undefined>();
const [logsEmitter] = useState(new EventEmitter());
Expand All @@ -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) => {
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 3966633

Please sign in to comment.