File tree Expand file tree Collapse file tree 3 files changed +83
-5
lines changed
apps/webapp/app/v3/models
internal-packages/run-engine/src/engine Expand file tree Collapse file tree 3 files changed +83
-5
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export async function findCurrentWorkerDeployment(
7171 id : true ,
7272 imageReference : true ,
7373 version : true ,
74+ type : true ,
7475 worker : {
7576 select : {
7677 id : true ,
@@ -88,7 +89,49 @@ export async function findCurrentWorkerDeployment(
8889 } ,
8990 } ) ;
9091
91- return promotion ?. deployment ;
92+ if ( ! promotion ) {
93+ return undefined ;
94+ }
95+
96+ if ( promotion . deployment . type === "V1" ) {
97+ // This is a run engine v1 deployment, so return it
98+ return promotion . deployment ;
99+ }
100+
101+ // We need to get the latest run engine v1 deployment
102+ const latestV1Deployment = await prisma . workerDeployment . findFirst ( {
103+ where : {
104+ environmentId,
105+ type : "V1" ,
106+ } ,
107+ orderBy : {
108+ id : "desc" ,
109+ } ,
110+ select : {
111+ id : true ,
112+ imageReference : true ,
113+ version : true ,
114+ type : true ,
115+ worker : {
116+ select : {
117+ id : true ,
118+ friendlyId : true ,
119+ version : true ,
120+ sdkVersion : true ,
121+ cliVersion : true ,
122+ supportsLazyAttempts : true ,
123+ tasks : true ,
124+ engine : true ,
125+ } ,
126+ } ,
127+ } ,
128+ } ) ;
129+
130+ if ( ! latestV1Deployment ) {
131+ return undefined ;
132+ }
133+
134+ return latestV1Deployment ;
92135}
93136
94137export async function getCurrentWorkerDeploymentEngineVersion (
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ export async function setupBackgroundWorker(
9797 runtimeEnvironmentId : environment . id ,
9898 version : nextVersion ,
9999 metadata : { } ,
100+ engine : "V2" ,
100101 } ,
101102 } ) ;
102103
@@ -234,6 +235,7 @@ export async function setupBackgroundWorker(
234235 projectId : environment . project . id ,
235236 environmentId : environment . id ,
236237 workerId : worker . id ,
238+ type : "MANAGED" ,
237239 } ,
238240 } ) ;
239241
You can’t perform that action at this time.
0 commit comments