Skip to content

Commit d9f2f7f

Browse files
committed
test 3
1 parent 728eb61 commit d9f2f7f

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

components/image-builder-api/typescript/src/sugar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ export class PromisifiedImageBuilderClient {
131131

132132
// build returns a nested promise. The outer one resolves/rejects with the build start,
133133
// the inner one resolves/rejects when the build is done.
134-
public build(ctx: TraceContext, request: BuildRequest): Promise<StagedBuildResponse> {
134+
public build(ctx: TraceContext, request: BuildRequest, logInfo: Deferred<ImageBuildLogInfo> = new Deferred<ImageBuildLogInfo>()): Promise<StagedBuildResponse> {
135135
const span = TraceContext.startSpan(`/image-builder/build`, ctx);
136136

137137
const buildResult = new Deferred<BuildResponse>();
138-
const logInfo = new Deferred<ImageBuildLogInfo>();
139138

140139
const result = new Deferred<StagedBuildResponse>();
141140
const resultResp: StagedBuildResponse = {
@@ -171,6 +170,7 @@ export class PromisifiedImageBuilderClient {
171170
resultResp.baseRef = resp.getBaseRef();
172171
}
173172

173+
log.warn(`BUILDINFO: ${JSON.stringify(resp.getInfo()?.toObject(), undefined, 2)}`)
174174
if (resp.hasInfo() && !logInfo.isResolved) {
175175
// assumes that log info stays stable for instance lifetime
176176
const info = resp.getInfo()

components/image-builder-mk3/pkg/orchestrator/monitor.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/hashicorp/go-retryablehttp"
2121
"golang.org/x/xerrors"
2222

23-
"github.com/gitpod-io/gitpod/common-go/kubernetes"
2423
"github.com/gitpod-io/gitpod/common-go/log"
2524
"github.com/gitpod-io/gitpod/common-go/tracing"
2625
"github.com/gitpod-io/gitpod/image-builder/api"

components/image-builder-mk3/pkg/orchestrator/monitor_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/google/go-cmp/cmp/cmpopts"
1313
"google.golang.org/protobuf/types/known/timestamppb"
1414

15-
"github.com/gitpod-io/gitpod/common-go/kubernetes"
1615
"github.com/gitpod-io/gitpod/image-builder/api"
1716
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
1817
)
@@ -89,9 +88,8 @@ func TestExtractBuildResponse(t *testing.T) {
8988
Metadata: &wsmanapi.WorkspaceMetadata{
9089
MetaId: buildID,
9190
Annotations: map[string]string{
92-
annotationRef: ref,
93-
annotationBaseRef: baseref,
94-
kubernetes.WorkspaceURLAnnotation: url,
91+
annotationRef: ref,
92+
annotationBaseRef: baseref,
9593
},
9694
StartedAt: timestamppb.New(time.Unix(startedAt, 0)),
9795
},
@@ -100,6 +98,9 @@ func TestExtractBuildResponse(t *testing.T) {
10098
Auth: &wsmanapi.WorkspaceAuthentication{
10199
OwnerToken: ownerToken,
102100
},
101+
Spec: &wsmanapi.WorkspaceSpec{
102+
Url: url,
103+
},
103104
}
104105
test.Mod(status)
105106
act := extractBuildResponse(status)

components/server/src/workspace/workspace-starter.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ import * as path from 'path';
3232
import * as grpc from "@grpc/grpc-js";
3333
import { IDEConfig, IDEConfigService } from "../ide-config";
3434
import { EnvVarWithValue } from "@gitpod/gitpod-protocol/src/protocol";
35-
import { WithReferrerContext } from "@gitpod/gitpod-protocol/lib/protocol";
35+
import { WithReferrerContext, ImageBuildLogInfo } from "@gitpod/gitpod-protocol/lib/protocol";
3636
import { IDEOption } from "@gitpod/gitpod-protocol/lib/ide-protocol";
37+
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred";
3738

3839
export interface StartWorkspaceOptions {
3940
rethrow?: boolean;
@@ -568,20 +569,21 @@ export class WorkspaceStarter {
568569
req.setAuth(auth);
569570
req.setForcerebuild(forceRebuild);
570571

571-
const result = await client.build({ span }, req);
572+
// Make sure we persist logInfo as soon as we retrieve it
573+
const imageBuildLogInfo = new Deferred<ImageBuildLogInfo>();
574+
imageBuildLogInfo.promise.then(async logInfo => {
575+
await this.workspaceDb.trace({span}).updatePartial(workspace.id, {
576+
imageBuildLogInfo: logInfo,
577+
}).catch(err => log.error("error writing image build log info to the DB", err));
578+
}).catch(err => log.warn("image build: never received log info"));
579+
580+
const result = await client.build({ span }, req, imageBuildLogInfo);
572581

573582
// Update the workspace now that we know what the name of the workspace image will be (which doubles as buildID)
574583
workspace.imageNameResolved = result.ref;
575584
span.log({ "ref": workspace.imageNameResolved });
576585
await this.workspaceDb.trace({ span }).store(workspace);
577586

578-
// Make sure we persist logInfo once we retrieve it
579-
result.logPromise.then(async logInfo => {
580-
await this.workspaceDb.trace({span}).updatePartial(workspace.id, {
581-
imageBuildLogInfo: logInfo,
582-
}).catch(err => log.error("error writing image build log info to the DB", err));
583-
}).catch(err => log.warn("image build: never received log info"));
584-
585587
// Update workspace instance to tell the world we're building an image
586588
const workspaceImage = result.ref;
587589
const status: WorkspaceInstanceStatus = result.actuallyNeedsBuild ? { ...instance.status, phase: 'preparing' } : instance.status;

0 commit comments

Comments
 (0)