Skip to content

[ws-manager-bridge] update prebuild state properly #7968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions components/ws-manager-bridge/ee/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,21 @@ export class WorkspaceManagerBridgeEE extends WorkspaceManagerBridge {
}
}

protected async controlPrebuildInstance(instance: WorkspaceInstance): Promise<void> {
protected async stopPrebuildInstance(ctx: TraceContext, instance: WorkspaceInstance): Promise<void> {
const span = TraceContext.startSpan("stopPrebuildInstance", ctx);

const prebuild = await this.workspaceDB.trace({}).findPrebuildByWorkspaceID(instance.workspaceId);
if (prebuild && prebuild.state == 'building') {
if (prebuild) {
// this is a prebuild - set it to aborted
prebuild.state = 'aborted';
await this.workspaceDB.trace({}).storePrebuiltWorkspace(prebuild);

{ // notify about prebuild updated
const info = (await this.workspaceDB.trace({span}).findPrebuildInfos([prebuild.id]))[0];
if (info) {
this.messagebus.notifyOnPrebuildUpdate({ info, status: prebuild.state });
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/ws-manager-bridge/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class WorkspaceManagerBridge implements Disposable {
instance.stoppedTime = new Date().toISOString();
promises.push(this.workspaceDB.trace({}).storeInstance(instance));
promises.push(this.onInstanceStopped({}, ri.workspace.ownerId, instance));
promises.push(this.controlPrebuildInstance(instance));
promises.push(this.stopPrebuildInstance(ctx, instance));
}
await Promise.all(promises);
}
Expand All @@ -325,7 +325,7 @@ export class WorkspaceManagerBridge implements Disposable {
// prebuilds are an EE feature - we just need the hook here
}

protected async controlPrebuildInstance(instance: WorkspaceInstance): Promise<void> {
protected async stopPrebuildInstance(ctx: TraceContext, instance: WorkspaceInstance): Promise<void> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming, because this function is called in a single context, i.e. only when the status of a prebuild workspace instance is adjusted.

// prebuilds are an EE feature - we just need the hook here
}

Expand Down