diff --git a/.server-changes/skip-waiting-for-deploy-on-v2-promotes.md b/.server-changes/skip-waiting-for-deploy-on-v2-promotes.md new file mode 100644 index 0000000000..883a8c6ed9 --- /dev/null +++ b/.server-changes/skip-waiting-for-deploy-on-v2-promotes.md @@ -0,0 +1,6 @@ +--- +area: webapp +type: fix +--- + +Skip the legacy V1 `WAITING_FOR_DEPLOY` drain on V2 deployment promotions. A new `LEGACY_RUN_ENGINE_WAITING_FOR_DEPLOY_DISABLED` env var also acts as a kill-switch for any already-enqueued jobs. diff --git a/apps/webapp/app/env.server.ts b/apps/webapp/app/env.server.ts index e799162abe..97b8333e27 100644 --- a/apps/webapp/app/env.server.ts +++ b/apps/webapp/app/env.server.ts @@ -1016,6 +1016,7 @@ const EnvironmentSchema = z LEGACY_RUN_ENGINE_WAITING_FOR_DEPLOY_BATCH_SIZE: z.coerce.number().int().default(100), LEGACY_RUN_ENGINE_WAITING_FOR_DEPLOY_BATCH_STAGGER_MS: z.coerce.number().int().default(1_000), + LEGACY_RUN_ENGINE_WAITING_FOR_DEPLOY_DISABLED: z.string().default("0"), COMMON_WORKER_ENABLED: z.string().default(process.env.WORKER_ENABLED ?? "true"), COMMON_WORKER_CONCURRENCY_WORKERS: z.coerce.number().int().default(2), diff --git a/apps/webapp/app/v3/services/changeCurrentDeployment.server.ts b/apps/webapp/app/v3/services/changeCurrentDeployment.server.ts index 6022c17290..693e893e85 100644 --- a/apps/webapp/app/v3/services/changeCurrentDeployment.server.ts +++ b/apps/webapp/app/v3/services/changeCurrentDeployment.server.ts @@ -175,7 +175,17 @@ export class ChangeCurrentDeploymentService extends BaseService { }); } - await ExecuteTasksWaitingForDeployService.enqueue(deployment.workerId); + // Only V1 engine workers need the WAITING_FOR_DEPLOY drain — V2 runs sit + // in PENDING_VERSION and are handled out of band, so enqueuing here for V2 + // just produces empty scans of the TaskRun status index. + const worker = await this._prisma.backgroundWorker.findFirst({ + where: { id: deployment.workerId }, + select: { engine: true }, + }); + + if (worker?.engine === "V1") { + await ExecuteTasksWaitingForDeployService.enqueue(deployment.workerId); + } } async #syncSchedulesForDeployment(deployment: WorkerDeployment) { diff --git a/apps/webapp/app/v3/services/executeTasksWaitingForDeploy.ts b/apps/webapp/app/v3/services/executeTasksWaitingForDeploy.ts index 7839b9e6e0..fb519b4315 100644 --- a/apps/webapp/app/v3/services/executeTasksWaitingForDeploy.ts +++ b/apps/webapp/app/v3/services/executeTasksWaitingForDeploy.ts @@ -7,6 +7,12 @@ import { BaseService } from "./baseService.server"; export class ExecuteTasksWaitingForDeployService extends BaseService { public async call(backgroundWorkerId: string) { + // Kill-switch for the legacy V1 WAITING_FOR_DEPLOY drain. Set to "1" to + // neuter any jobs already enqueued (V2 has its own PENDING_VERSION path). + if (env.LEGACY_RUN_ENGINE_WAITING_FOR_DEPLOY_DISABLED === "1") { + return; + } + const backgroundWorker = await this._prisma.backgroundWorker.findFirst({ where: { id: backgroundWorkerId,