feat(supervisor): add flag to enable compute snapshots
🚀 Publish Trigger.dev Docker / units (push) Failing after 11m20s
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 11m20s
🚀 Publish Trigger.dev Docker / publish-webapp (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker (push) Has been skipped
🚀 Publish Trigger.dev Docker / publish-worker-v4 (push) Has been skipped

Gates snapshot/restore behaviour independently of compute mode.
When disabled, VMs won't receive the metadata URL and suspend/restore
are no-ops. Defaults to off so compute mode can be used without snapshots.
This commit is contained in:
nicktrn
2026-02-21 11:28:26 +00:00
parent 0a6d6f1a84
commit 4332743944
4 changed files with 14 additions and 9 deletions
+1
View File
@@ -81,6 +81,7 @@ const Env = z.object({
COMPUTE_GATEWAY_URL: z.string().url().optional(),
COMPUTE_GATEWAY_AUTH_TOKEN: z.string().optional(),
COMPUTE_GATEWAY_TIMEOUT_MS: z.coerce.number().int().default(30_000),
COMPUTE_SNAPSHOTS_ENABLED: BoolEnv.default(false),
// Kubernetes settings
KUBERNETES_FORCE_ENABLED: BoolEnv.default(false),
+1 -1
View File
@@ -223,7 +223,7 @@ class ManagedSupervisor {
if (checkpoint) {
this.logger.log("Restoring run", { runId: message.run.id });
if (this.isComputeMode && this.computeManager) {
if (this.isComputeMode && this.computeManager && env.COMPUTE_SNAPSHOTS_ENABLED) {
try {
// Derive runnerId unique per restore cycle (matches iceman's pattern)
const runIdShort = message.run.friendlyId.replace("run_", "");
+11 -7
View File
@@ -51,7 +51,7 @@ export class ComputeWorkloadManager implements WorkloadManager {
envVars.TRIGGER_WARM_START_URL = this.opts.warmStartUrl;
}
if (this.opts.metadataUrl) {
if (env.COMPUTE_SNAPSHOTS_ENABLED && this.opts.metadataUrl) {
envVars.TRIGGER_METADATA_URL = this.opts.metadataUrl;
}
@@ -266,17 +266,21 @@ export class ComputeWorkloadManager implements WorkloadManager {
TRIGGER_WORKER_INSTANCE_NAME: env.TRIGGER_WORKER_INSTANCE_NAME,
};
const body = {
name: opts.runnerId,
metadata,
cpu: opts.machine.cpu,
memory_mb: opts.machine.memory * 1024,
};
this.logger.debug("restore request body", { url, body });
const [error, response] = await tryCatch(
fetch(url, {
method: "POST",
headers: this.authHeaders,
signal: AbortSignal.timeout(this.opts.gatewayTimeoutMs),
body: JSON.stringify({
name: opts.runnerId,
metadata,
cpu: opts.machine.cpu,
memory_mb: opts.machine.memory * 1024,
}),
body: JSON.stringify(body),
})
);
+1 -1
View File
@@ -263,7 +263,7 @@ export class WorkloadServer extends EventEmitter<WorkloadServerEvents> {
return;
}
if (this.computeManager) {
if (this.computeManager && env.COMPUTE_SNAPSHOTS_ENABLED) {
// Compute mode: fire-and-forget snapshot with callback
reply.json({ ok: true } satisfies WorkloadSuspendRunResponseBody, false, 202);