From 812d91b67ef512b49b1d66053dbb3f1411aa2b6c Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Mon, 25 May 2026 06:38:11 +0100 Subject: [PATCH] fix(webapp): skip V1 WAITING_FOR_DEPLOY drain on V2 promotes --- .../skip-waiting-for-deploy-on-v2-promotes.md | 6 ++++++ apps/webapp/app/env.server.ts | 1 + .../v3/services/changeCurrentDeployment.server.ts | 12 +++++++++++- .../app/v3/services/executeTasksWaitingForDeploy.ts | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .server-changes/skip-waiting-for-deploy-on-v2-promotes.md 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 00000000000..883a8c6ed99 --- /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 e799162abe0..97b8333e279 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 6022c172908..693e893e854 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 7839b9e6e07..fb519b43151 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,