Skip to content

Commit b846780

Browse files
committed
HeadlessLogEndpoint
1 parent 9ca9103 commit b846780

File tree

3 files changed

+90
-74
lines changed

3 files changed

+90
-74
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { WorkspaceDeletionService } from './workspace-deletion-service';
4646
import { WorkspaceFactory } from './workspace-factory';
4747
import { WorkspaceStarter } from './workspace-starter';
4848
import { HeadlessLogUrls } from "@gitpod/gitpod-protocol/lib/headless-workspace-log";
49-
import { HeadlessLogService, WorkspaceInstanceEndpoint } from "./headless-log-service";
49+
import { HeadlessLogService, HeadlessLogEndpoint } from "./headless-log-service";
5050
import { InvalidGitpodYMLError } from "./config-provider";
5151
import { ProjectsService } from "../projects/projects-service";
5252
import { LocalMessageBroker } from "../messaging/local-message-broker";
@@ -1145,14 +1145,13 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
11451145

11461146
const aborted = new Deferred<boolean>();
11471147
try {
1148-
const wsiEndpoint: WorkspaceInstanceEndpoint = {
1149-
instanceId: instance.id,
1148+
const logEndpoint: HeadlessLogEndpoint = {
11501149
url: workspace.imageBuildLogInfo.url,
11511150
headers: workspace.imageBuildLogInfo.headers,
11521151
};
1153-
log.info(`WSIE: ${JSON.stringify(wsiEndpoint, undefined, 2)}`);
1152+
log.info(`WSIE: ${JSON.stringify(logEndpoint, undefined, 2)}`);
11541153
let lineCount = 0;
1155-
await this.headlessLogService.streamImageBuildLog(wsiEndpoint, async (chunk) => {
1154+
await this.headlessLogService.streamImageBuildLog(logCtx, logEndpoint, async (chunk) => {
11561155
if (aborted.isResolved) {
11571156
return;
11581157
}
@@ -1209,6 +1208,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
12091208
traceAPIParams(ctx, { instanceId });
12101209

12111210
this.checkAndBlockUser('getHeadlessLog', { instanceId });
1211+
const logCtx: LogContext = { instanceId };
12121212

12131213
const ws = await this.workspaceDb.trace(ctx).findByInstanceId(instanceId);
12141214
if (!ws) {
@@ -1225,7 +1225,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
12251225
throw new ResponseError(ErrorCodes.NOT_FOUND, `Workspace instance for ${instanceId} not found`);
12261226
}
12271227

1228-
const urls = await this.headlessLogService.getHeadlessLogURLs(wsi, ws.ownerId);
1228+
const urls = await this.headlessLogService.getHeadlessLogURLs(logCtx, wsi, ws.ownerId);
12291229
if (!urls || (typeof urls.streams === "object" && Object.keys(urls.streams).length === 0)) {
12301230
throw new ResponseError(ErrorCodes.NOT_FOUND, `Headless logs for ${instanceId} not found`);
12311231
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CompositeResourceAccessGuard, OwnerResourceGuard, TeamMemberResourceGua
1212
import { DBWithTracing, TracedWorkspaceDB } from "@gitpod/gitpod-db/lib/traced-db";
1313
import { WorkspaceDB } from "@gitpod/gitpod-db/lib/workspace-db";
1414
import { TeamDB } from "@gitpod/gitpod-db/lib/team-db";
15-
import { HeadlessLogService, WorkspaceInstanceEndpoint } from "./headless-log-service";
15+
import { HeadlessLogService, HeadlessLogEndpoint } from "./headless-log-service";
1616
import * as opentracing from 'opentracing';
1717
import { asyncHandler } from "../express-util";
1818
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred";
@@ -88,8 +88,8 @@ export class HeadlessLogController {
8888
process.nextTick(resolve);
8989
}
9090
}));
91-
const wsiEndpoint = WorkspaceInstanceEndpoint.fromWithOwnerToken(instance);
92-
await this.headlessLogService.streamWorkspaceLog(wsiEndpoint, params.terminalId, writeToResponse, aborted);
91+
const logEndpoint = HeadlessLogEndpoint.fromWithOwnerToken(instance);
92+
await this.headlessLogService.streamWorkspaceLogWhileRunning(logCtx, logEndpoint, instanceId, params.terminalId, writeToResponse, aborted);
9393

9494
// In an ideal world, we'd use res.addTrailers()/response.trailer here. But despite being introduced with HTTP/1.1 in 1999, trailers are not supported by popular proxies (nginx, for example).
9595
// So we resort to this hand-written solution

0 commit comments

Comments
 (0)