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(
71
71
id : true ,
72
72
imageReference : true ,
73
73
version : true ,
74
+ type : true ,
74
75
worker : {
75
76
select : {
76
77
id : true ,
@@ -88,7 +89,49 @@ export async function findCurrentWorkerDeployment(
88
89
} ,
89
90
} ) ;
90
91
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 ;
92
135
}
93
136
94
137
export async function getCurrentWorkerDeploymentEngineVersion (
Original file line number Diff line number Diff line change @@ -289,10 +289,43 @@ export async function getWorkerFromCurrentlyPromotedDeployment(
289
289
return null ;
290
290
}
291
291
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
+
292
325
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 ,
297
330
} ;
298
331
}
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ export async function setupBackgroundWorker(
97
97
runtimeEnvironmentId : environment . id ,
98
98
version : nextVersion ,
99
99
metadata : { } ,
100
+ engine : "V2" ,
100
101
} ,
101
102
} ) ;
102
103
@@ -234,6 +235,7 @@ export async function setupBackgroundWorker(
234
235
projectId : environment . project . id ,
235
236
environmentId : environment . id ,
236
237
workerId : worker . id ,
238
+ type : "MANAGED" ,
237
239
} ,
238
240
} ) ;
239
241
You can’t perform that action at this time.
0 commit comments