Skip to content

Commit 704c638

Browse files
committed
run engine v2 will only lock to managed v2 deployments
1 parent 6a69ed6 commit 704c638

File tree

1 file changed

+37
-4
lines changed
  • internal-packages/run-engine/src/engine/db

1 file changed

+37
-4
lines changed

internal-packages/run-engine/src/engine/db/worker.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,43 @@ export async function getWorkerFromCurrentlyPromotedDeployment(
289289
return null;
290290
}
291291

292+
if (promotion.deployment.type === "MANAGED") {
293+
// This is a run engine v2 deployment, so return it
294+
return {
295+
worker: promotion.deployment.worker,
296+
tasks: promotion.deployment.worker.tasks,
297+
queues: promotion.deployment.worker.queues,
298+
deployment: promotion.deployment,
299+
};
300+
}
301+
302+
// We need to get the latest run engine v2 deployment
303+
const latestV2Deployment = await prisma.workerDeployment.findFirst({
304+
where: {
305+
environmentId,
306+
type: "MANAGED",
307+
},
308+
orderBy: {
309+
id: "desc",
310+
},
311+
include: {
312+
worker: {
313+
include: {
314+
tasks: true,
315+
queues: true,
316+
},
317+
},
318+
},
319+
});
320+
321+
if (!latestV2Deployment?.worker) {
322+
return null;
323+
}
324+
292325
return {
293-
worker: promotion.deployment.worker,
294-
tasks: promotion.deployment.worker.tasks,
295-
queues: promotion.deployment.worker.queues,
296-
deployment: promotion.deployment,
326+
worker: latestV2Deployment.worker,
327+
tasks: latestV2Deployment.worker.tasks,
328+
queues: latestV2Deployment.worker.queues,
329+
deployment: latestV2Deployment,
297330
};
298331
}

0 commit comments

Comments
 (0)