Skip to content

Commit 6bf9dc8

Browse files
committed
Fix prebuild checks
1 parent 7766d3b commit 6bf9dc8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

components/server/src/prebuilds/prebuild-manager.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface StartPrebuildParams {
4949
commitInfo?: CommitInfo;
5050
forcePrebuild?: boolean;
5151
trigger?: keyof ProjectUsage;
52+
ignoreInactiveProject?: boolean;
5253
}
5354

5455
export interface PrebuildFilter {
@@ -330,7 +331,15 @@ export class PrebuildManager {
330331

331332
async startPrebuild(
332333
ctx: TraceContext,
333-
{ context, project, user, commitInfo, forcePrebuild, trigger = "lastWebhookReceived" }: StartPrebuildParams,
334+
{
335+
context,
336+
project,
337+
user,
338+
commitInfo,
339+
forcePrebuild,
340+
trigger = "lastWebhookReceived",
341+
ignoreInactiveProject,
342+
}: StartPrebuildParams,
334343
): Promise<StartPrebuildResult> {
335344
const span = TraceContext.startSpan("startPrebuild", ctx);
336345
const cloneURL = context.repository.cloneUrl;
@@ -461,7 +470,10 @@ export class PrebuildManager {
461470
"Prebuild is rate limited. Please contact Gitpod if you believe this happened in error.";
462471
await this.workspaceDB.trace({ span }).storePrebuiltWorkspace(prebuild);
463472
span.setTag("ratelimited", true);
464-
} else if (await this.projectService.isProjectConsideredInactive(user.id, project.id)) {
473+
} else if (
474+
!ignoreInactiveProject &&
475+
(await this.projectService.isProjectConsideredInactive(user.id, project.id))
476+
) {
465477
prebuild.state = "aborted";
466478
prebuild.error =
467479
"Project is inactive. Please start a new workspace for this project to re-enable prebuilds.";
@@ -661,7 +673,7 @@ export class PrebuildManager {
661673
if (!prebuild || !organizationId) {
662674
throw new ApplicationError(ErrorCodes.PRECONDITION_FAILED, "prebuild workspace not found");
663675
}
664-
await this.auth.checkPermissionOnOrganization(userId, "read_prebuild", organizationId);
676+
await this.auth.checkPermissionOnProject(userId, "read_prebuild", organizationId);
665677

666678
const instance = await this.workspaceService.getCurrentInstance(userId, prebuild.workspace.id, {
667679
skipPermissionCheck: true,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ export class WorkspaceService {
455455
forcePrebuild: false,
456456
context,
457457
trigger: "lastWorkspaceStart",
458+
ignoreInactiveProject: true,
458459
});
459460
log.info(logCtx, "starting prebuild after workspace creation", {
460461
projectId: project.id,

0 commit comments

Comments
 (0)