Skip to content

Commit f834ace

Browse files
committed
feat(webapp): resolve env-level default region in trigger path
getDefaultWorkerGroupForProject now checks the environment default before the project default. Adds resolveEffectiveDefaultWorkerGroupId as the shared fallback chain (env -> project -> global).
1 parent 5ab883f commit f834ace

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

apps/webapp/app/runEngine/concerns/queues.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ export class DefaultQueueManager implements QueueManager {
389389
const [error, workerGroup] = await tryCatch(
390390
workerGroupService.getDefaultWorkerGroupForProject({
391391
projectId: environment.projectId,
392+
environmentDefaultWorkerGroupId: environment.defaultWorkerGroupId,
392393
regionOverride,
393394
})
394395
);

apps/webapp/app/v3/regionAccess.server.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ export function defaultVisibilityFilter(
3333
return { hidden: false, workloadType: { not: "MICROVM" } };
3434
}
3535

36+
/**
37+
* Canonical fallback chain for a run's default region:
38+
* environment default -> project default -> global default.
39+
* Both the trigger path and the regions UI must use this order so the
40+
* displayed default matches what actually runs.
41+
*/
42+
export function resolveEffectiveDefaultWorkerGroupId({
43+
environmentDefaultWorkerGroupId,
44+
projectDefaultWorkerGroupId,
45+
globalDefaultWorkerGroupId,
46+
}: {
47+
environmentDefaultWorkerGroupId?: string | null;
48+
projectDefaultWorkerGroupId?: string | null;
49+
globalDefaultWorkerGroupId?: string | null;
50+
}): string | undefined {
51+
return (
52+
environmentDefaultWorkerGroupId ??
53+
projectDefaultWorkerGroupId ??
54+
globalDefaultWorkerGroupId ??
55+
undefined
56+
);
57+
}
58+
3659
/**
3760
* Whether a region is accessible given compute access.
3861
* MICROVM regions require compute access; all other types pass through.

apps/webapp/app/v3/services/worker/workerGroupService.server.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,11 @@ export class WorkerGroupService extends WithRunEngine {
220220

221221
async getDefaultWorkerGroupForProject({
222222
projectId,
223+
environmentDefaultWorkerGroupId,
223224
regionOverride,
224225
}: {
225226
projectId: string;
227+
environmentDefaultWorkerGroupId?: string | null;
226228
regionOverride?: string;
227229
}): Promise<WorkerInstanceGroup | undefined> {
228230
const project = await this._prisma.project.findFirst({
@@ -282,6 +284,18 @@ export class WorkerGroupService extends WithRunEngine {
282284
return workerGroup;
283285
}
284286

287+
// Resolution order must match resolveEffectiveDefaultWorkerGroupId:
288+
// environment default -> project default -> global default.
289+
if (environmentDefaultWorkerGroupId) {
290+
const envWorkerGroup = await this._prisma.workerInstanceGroup.findFirst({
291+
where: { id: environmentDefaultWorkerGroupId },
292+
});
293+
294+
if (envWorkerGroup) {
295+
return envWorkerGroup;
296+
}
297+
}
298+
285299
if (project.defaultWorkerGroup) {
286300
return project.defaultWorkerGroup;
287301
}

0 commit comments

Comments
 (0)