Skip to content

Commit 7ed9221

Browse files
committed
fix(supervisor): require workload API domain when compute snapshots enabled
Remove the silent `localhost` fallback for the snapshot callback URL, which would be unreachable from external compute gateways. Add env validation and a runtime guard matching the existing metadata URL pattern.
1 parent 5089bba commit 7ed9221

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

apps/supervisor/src/env.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ const Env = z
159159
path: ["TRIGGER_METADATA_URL"],
160160
});
161161
}
162+
if (data.COMPUTE_SNAPSHOTS_ENABLED && !data.TRIGGER_WORKLOAD_API_DOMAIN) {
163+
ctx.addIssue({
164+
code: z.ZodIssueCode.custom,
165+
message: "TRIGGER_WORKLOAD_API_DOMAIN is required when COMPUTE_SNAPSHOTS_ENABLED is true",
166+
path: ["TRIGGER_WORKLOAD_API_DOMAIN"],
167+
});
168+
}
162169
});
163170

164171
export const env = Env.parse(stdEnv);

apps/supervisor/src/workloadServer/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,18 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
264264
}
265265

266266
if (this.computeManager && env.COMPUTE_SNAPSHOTS_ENABLED) {
267+
if (!env.TRIGGER_WORKLOAD_API_DOMAIN) {
268+
this.logger.error(
269+
"TRIGGER_WORKLOAD_API_DOMAIN is not set, cannot create snapshot callback URL"
270+
);
271+
reply.json({ error: "Snapshot callbacks not configured" }, false, 500);
272+
return;
273+
}
274+
267275
// Compute mode: fire-and-forget snapshot with callback
268276
reply.json({ ok: true } satisfies WorkloadSuspendRunResponseBody, false, 202);
269277

270-
const callbackUrl = `${env.TRIGGER_WORKLOAD_API_PROTOCOL}://${
271-
env.TRIGGER_WORKLOAD_API_DOMAIN ?? "localhost"
272-
}:${env.TRIGGER_WORKLOAD_API_PORT_EXTERNAL}/api/v1/compute/snapshot-complete`;
278+
const callbackUrl = `${env.TRIGGER_WORKLOAD_API_PROTOCOL}://${env.TRIGGER_WORKLOAD_API_DOMAIN}:${env.TRIGGER_WORKLOAD_API_PORT_EXTERNAL}/api/v1/compute/snapshot-complete`;
273279

274280
const snapshotResult = await this.computeManager.snapshot({
275281
runnerId,

0 commit comments

Comments
 (0)