Skip to content

Commit 7f62aee

Browse files
committed
treat immediate retries as warm starts
1 parent d2a0177 commit 7f62aee

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

packages/cli-v3/src/entryPoints/managed-run-controller.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ class ManagedRunController {
579579
runId: run.friendlyId,
580580
message: "Run is finished, will wait for next run",
581581
});
582-
this.waitForNextRun();
582+
this.waitForNextRun();
583583
return;
584584
}
585585
case "QUEUED_EXECUTING":
@@ -983,7 +983,14 @@ class ManagedRunController {
983983
};
984984

985985
try {
986-
return await this.executeRun({ run, snapshot, envVars: taskRunEnv, execution, metrics });
986+
return await this.executeRun({
987+
run,
988+
snapshot,
989+
envVars: taskRunEnv,
990+
execution,
991+
metrics,
992+
isWarmStart,
993+
});
987994
} catch (error) {
988995
if (error instanceof SuspendedProcessError) {
989996
this.sendDebugLog({
@@ -1344,8 +1351,10 @@ class ManagedRunController {
13441351
envVars,
13451352
execution,
13461353
metrics,
1354+
isWarmStart,
13471355
}: WorkloadRunAttemptStartResponseBody & {
13481356
metrics?: TaskRunExecutionMetrics;
1357+
isWarmStart?: boolean;
13491358
}) {
13501359
this.snapshotPoller.start();
13511360

@@ -1360,6 +1369,7 @@ class ManagedRunController {
13601369
engine: "V2",
13611370
},
13621371
machine: execution.machine,
1372+
isWarmStart,
13631373
}).initialize();
13641374
}
13651375

@@ -1372,15 +1382,18 @@ class ManagedRunController {
13721382
},
13731383
});
13741384

1375-
const completion = await this.taskRunProcess.execute({
1376-
payload: {
1377-
execution,
1378-
traceContext: execution.run.traceContext ?? {},
1379-
metrics,
1385+
const completion = await this.taskRunProcess.execute(
1386+
{
1387+
payload: {
1388+
execution,
1389+
traceContext: execution.run.traceContext ?? {},
1390+
metrics,
1391+
},
1392+
messageId: run.friendlyId,
1393+
env: envVars,
13801394
},
1381-
messageId: run.friendlyId,
1382-
env: envVars,
1383-
});
1395+
isWarmStart
1396+
);
13841397

13851398
this.sendDebugLog({
13861399
runId: this.runFriendlyId,
@@ -1543,6 +1556,7 @@ class ManagedRunController {
15431556
runFriendlyId: run.friendlyId,
15441557
snapshotFriendlyId: this.snapshotFriendlyId,
15451558
skipLockCheckForImmediateRetry: true,
1559+
isWarmStart: true,
15461560
}).finally(() => {});
15471561
return;
15481562
}

packages/cli-v3/src/executions/taskRunProcess.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ export class TaskRunProcess {
215215
await this._ipc?.sendWithAck("FLUSH", { timeoutInMs }, timeoutInMs + 1_000);
216216
}
217217

218-
async execute(params: TaskRunProcessExecuteParams): Promise<TaskRunExecutionResult> {
218+
async execute(
219+
params: TaskRunProcessExecuteParams,
220+
isWarmStart?: boolean
221+
): Promise<TaskRunExecutionResult> {
219222
this._isPreparedForNextRun = false;
220223

221224
let resolver: (value: TaskRunExecutionResult) => void;
@@ -251,7 +254,7 @@ export class TaskRunProcess {
251254
metadata: this.options.serverWorker,
252255
metrics,
253256
env: params.env,
254-
isWarmStart: this.options.isWarmStart,
257+
isWarmStart: isWarmStart ?? this.options.isWarmStart,
255258
});
256259
}
257260

packages/core/src/v3/workers/taskExecutor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export class TaskExecutor {
8989
execution: TaskRunExecution,
9090
worker: ServerBackgroundWorker,
9191
traceContext: Record<string, unknown>,
92-
signal?: AbortSignal
92+
signal?: AbortSignal,
93+
isWarmStart?: boolean
9394
): Promise<{ result: TaskRunExecutionResult }> {
9495
const ctx = TaskRunContext.parse(execution);
9596
const attemptMessage = `Attempt ${execution.attempt.number}`;
@@ -102,7 +103,7 @@ export class TaskExecutor {
102103
taskContext.setGlobalTaskContext({
103104
ctx,
104105
worker,
105-
isWarmStart: this._isWarmStart,
106+
isWarmStart: isWarmStart ?? this._isWarmStart,
106107
});
107108

108109
if (execution.run.metadata) {

0 commit comments

Comments
 (0)