Skip to content

Commit 1834da4

Browse files
committed
fix(supervisor): address review feedback on compute workload manager
1 parent d0445ef commit 1834da4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

apps/supervisor/src/services/timerWheel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class TimerWheel<T> {
4646
this.cursor = 0;
4747
this.intervalId = null;
4848
this.onExpire = opts.onExpire;
49-
this.delaySlots = Math.max(1, Math.min(NUM_SLOTS, Math.round(opts.delayMs / TICK_MS)));
49+
this.delaySlots = Math.max(1, Math.min(NUM_SLOTS, Math.ceil(opts.delayMs / TICK_MS)));
5050
}
5151

5252
/** Start the timer wheel. Must be called before submitting items. */
@@ -88,7 +88,7 @@ export class TimerWheel<T> {
8888
* Clamped to [TICK_MS, 60000ms].
8989
*/
9090
setDelay(delayMs: number): void {
91-
this.delaySlots = Math.max(1, Math.min(NUM_SLOTS, Math.round(delayMs / TICK_MS)));
91+
this.delaySlots = Math.max(1, Math.min(NUM_SLOTS, Math.ceil(delayMs / TICK_MS)));
9292
}
9393

9494
/**

apps/supervisor/src/workloadServer/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
129129
if (this.computeManager && env.COMPUTE_SNAPSHOTS_ENABLED) {
130130
this.snapshotDelayWheel = new TimerWheel<DelayedSnapshot>({
131131
delayMs: env.COMPUTE_SNAPSHOT_DELAY_MS,
132-
onExpire: (item) => this.dispatchComputeSnapshot(item.data),
132+
onExpire: (item) => {
133+
this.dispatchComputeSnapshot(item.data).catch((error) => {
134+
this.logger.error("Compute snapshot dispatch failed", {
135+
runId: item.data.runFriendlyId,
136+
runnerId: item.data.runnerId,
137+
error,
138+
});
139+
});
140+
},
133141
});
134142
this.snapshotDelayWheel.start();
135143
}
@@ -296,7 +304,14 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
296304
this.logger.error(
297305
"TRIGGER_WORKLOAD_API_DOMAIN is not set, cannot create snapshot callback URL"
298306
);
299-
reply.json({ error: "Snapshot callbacks not configured" }, false, 500);
307+
reply.json(
308+
{
309+
ok: false,
310+
error: "Snapshot callbacks not configured",
311+
} satisfies WorkloadSuspendRunResponseBody,
312+
false,
313+
500
314+
);
300315
return;
301316
}
302317

0 commit comments

Comments
 (0)