@@ -43,7 +43,7 @@ import { RestoreCheckpointService } from "../services/restoreCheckpoint.server";
4343import { SEMINTATTRS_FORCE_RECORDING , tracer } from "../tracer.server" ;
4444import { generateJWTTokenForEnvironment } from "~/services/apiAuth.server" ;
4545import { EnvironmentVariable } from "../environmentVariables/repository" ;
46- import { machinePresetFromConfig } from "../machinePresets.server" ;
46+ import { machinePresetFromConfig , machinePresetFromRun } from "../machinePresets.server" ;
4747import { env } from "~/env.server" ;
4848import {
4949 FINAL_ATTEMPT_STATUSES ,
@@ -413,7 +413,9 @@ export class SharedQueueConsumer {
413413 cliVersion : deployment . worker . cliVersion ,
414414 startedAt : existingTaskRun . startedAt ?? new Date ( ) ,
415415 baseCostInCents : env . CENTS_PER_RUN ,
416- machinePreset : machinePresetFromConfig ( backgroundTask . machineConfig ?? { } ) . name ,
416+ machinePreset :
417+ existingTaskRun . machinePreset ??
418+ machinePresetFromConfig ( backgroundTask . machineConfig ?? { } ) . name ,
417419 maxDurationInSeconds : getMaxDuration (
418420 existingTaskRun . maxDurationInSeconds ,
419421 backgroundTask . maxDurationInSeconds
@@ -542,8 +544,9 @@ export class SharedQueueConsumer {
542544
543545 // Retries for workers with disabled retry checkpoints will be handled just like normal attempts
544546 } else {
545- const machineConfig = lockedTaskRun . lockedBy ?. machineConfig ;
546- const machine = machinePresetFromConfig ( machineConfig ?? { } ) ;
547+ const machine =
548+ machinePresetFromRun ( lockedTaskRun ) ??
549+ machinePresetFromConfig ( lockedTaskRun . lockedBy ?. machineConfig ?? { } ) ;
547550
548551 await this . _sender . send ( "BACKGROUND_WORKER_MESSAGE" , {
549552 backgroundWorkerId : deployment . worker . friendlyId ,
@@ -1077,7 +1080,9 @@ class SharedQueueTasks {
10771080 const { backgroundWorkerTask, taskRun, queue } = attempt ;
10781081
10791082 if ( ! machinePreset ) {
1080- machinePreset = machinePresetFromConfig ( backgroundWorkerTask . machineConfig ?? { } ) ;
1083+ machinePreset =
1084+ machinePresetFromRun ( attempt . taskRun ) ??
1085+ machinePresetFromConfig ( backgroundWorkerTask . machineConfig ?? { } ) ;
10811086 }
10821087
10831088 const metadata = await parsePacket ( {
@@ -1294,9 +1299,13 @@ class SharedQueueTasks {
12941299 } ,
12951300 } ) ;
12961301 }
1302+
12971303 const { backgroundWorkerTask, taskRun } = attempt ;
12981304
1299- const machinePreset = machinePresetFromConfig ( backgroundWorkerTask . machineConfig ?? { } ) ;
1305+ const machinePreset =
1306+ machinePresetFromRun ( attempt . taskRun ) ??
1307+ machinePresetFromConfig ( backgroundWorkerTask . machineConfig ?? { } ) ;
1308+
13001309 const execution = await this . _executionFromAttempt ( attempt , machinePreset ) ;
13011310 const variables = await this . #buildEnvironmentVariables(
13021311 attempt . runtimeEnvironment ,
@@ -1432,6 +1441,7 @@ class SharedQueueTasks {
14321441 machineConfig : true ,
14331442 } ,
14341443 } ,
1444+ machinePreset : true ,
14351445 } ,
14361446 } ) ;
14371447
@@ -1451,7 +1461,8 @@ class SharedQueueTasks {
14511461 attemptCount,
14521462 } ) ;
14531463
1454- const machinePreset = machinePresetFromConfig ( run . lockedBy ?. machineConfig ?? { } ) ;
1464+ const machinePreset =
1465+ machinePresetFromRun ( run ) ?? machinePresetFromConfig ( run . lockedBy ?. machineConfig ?? { } ) ;
14551466
14561467 const variables = await this . #buildEnvironmentVariables( environment , run . id , machinePreset ) ;
14571468
0 commit comments