Skip to content

[server] don't wait for queued prebuilds #17129

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
Apr 4, 2023
Merged
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
22 changes: 5 additions & 17 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,11 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
prebuiltWorkspace,
};
return result;
} else if (prebuiltWorkspace.state === "queued" || prebuiltWorkspace.state === "building") {
} else if (prebuiltWorkspace.state === "queued") {
// waiting for a prebuild that has not even started yet, doesn't make sense.
// starting a workspace from git will be faster anyway
return;
} else if (prebuiltWorkspace.state === "building") {
if (ignoreRunningPrebuild) {
// in force mode we ignore running prebuilds as we want to start a workspace as quickly as we can.
return;
Expand All @@ -986,22 +990,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {

const wsi = await this.workspaceDb.trace(ctx).findCurrentInstance(workspaceID);
if (!wsi || wsi.stoppedTime !== undefined) {
if (prebuiltWorkspace.state === "queued") {
if (Date.now() - Date.parse(prebuiltWorkspace.creationTime) > 1000 * 60) {
// queued for long than a minute? Let's retrigger
console.warn("Retriggering queued prebuild.", prebuiltWorkspace);
try {
const project = prebuiltWorkspace.projectId
? await this.projectDB.findProjectById(prebuiltWorkspace.projectId)
: undefined;
await this.prebuildManager.retriggerPrebuild(ctx, user, project, workspaceID);
} catch (err) {
console.error(err);
}
}
return makeResult(wsi!.id);
}

return;
}

Expand Down