Skip to content

Commit d85d770

Browse files
committed
fix(supervisor): treat a missing cancel route as unsupported, not an error
1 parent 4d5e413 commit d85d770

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

apps/supervisor/src/workloadServer/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const checkpointDeleteRequests = new Counter({
6363
const checkpointCancelRequests = new Counter({
6464
name: "checkpoint_cancel_requests_total",
6565
help: "Checkpoint cancel requests attempted when a run continues, by outcome",
66-
labelNames: ["result"], // "sent" | "no_client" | "not_applicable" | "http_error"
66+
labelNames: ["result"],
6767
registers: [register],
6868
});
6969

@@ -306,16 +306,22 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
306306
return;
307307
}
308308

309-
const [error, accepted] = await tryCatch(
309+
const [error, outcome] = await tryCatch(
310310
this.checkpointClient.cancelCheckpoints({ runFriendlyId })
311311
);
312312

313-
if (error || !accepted) {
313+
if (error || outcome === "failed") {
314314
checkpointCancelRequests.inc({ result: "http_error" });
315315
this.logger.error("Failed to request checkpoint cancel", { runFriendlyId, error });
316316
return;
317317
}
318318

319+
if (outcome === "unsupported") {
320+
checkpointCancelRequests.inc({ result: "unsupported" });
321+
this.logger.debug("Checkpoint cancel not supported", { runFriendlyId });
322+
return;
323+
}
324+
319325
checkpointCancelRequests.inc({ result: "sent" });
320326
}
321327

packages/core/src/v3/serverOnly/checkpointClient.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,32 @@ export class CheckpointClient {
158158
return true;
159159
}
160160

161-
async cancelCheckpoints({ runFriendlyId }: { runFriendlyId: string }): Promise<boolean> {
161+
/**
162+
* cancelCheckpoints returns "unsupported" when the route is absent, which is expected while a
163+
* newer caller runs against an older checkpoint service.
164+
*/
165+
async cancelCheckpoints({
166+
runFriendlyId,
167+
}: {
168+
runFriendlyId: string;
169+
}): Promise<"ok" | "unsupported" | "failed"> {
162170
const res = await fetch(
163171
new URL(`/api/v1/runs/${runFriendlyId}/checkpoints/cancel`, this.opts.apiUrl),
164172
{ method: "POST" }
165173
);
166174

175+
if (res.status === 404) {
176+
return "unsupported";
177+
}
178+
167179
if (!res.ok) {
168180
this.logger.error("[CheckpointClient] Cancel checkpoints request failed", {
169181
runFriendlyId,
170182
status: res.status,
171183
});
172-
return false;
184+
return "failed";
173185
}
174186

175-
return true;
187+
return "ok";
176188
}
177189
}

0 commit comments

Comments
 (0)