Skip to content

Commit 8fcb035

Browse files
1stvampTrigger.dev RepoOps
authored andcommitted
refactor(supervisor,webapp): remove the compute gateway path
Remove the unused compute gateway integration from the supervisor and webapp, along with the internal compute client package. Mono-RevId: 7fad1730cdc6eac639f9df2300a599732d3b0a5d
1 parent f9fd2b8 commit 8fcb035

31 files changed

Lines changed: 89 additions & 2479 deletions

‎apps/supervisor/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
},
1717
"dependencies": {
1818
"@aws-sdk/client-ecr": "^3.839.0",
19-
"@internal/compute": "workspace:*",
2019
"@kubernetes/client-node": "^1.0.0",
2120
"@trigger.dev/core": "workspace:*",
2221
"dockerode": "^4.0.6",

‎apps/supervisor/src/env.test.ts‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ describe("worker queue selection", () => {
7878
it.each([
7979
{ config: {}, subscription: { ...ondemand, compat: "compute" }, error: "compatibility" },
8080
{
81-
config: { COMPUTE_GATEWAY_URL: "http://localhost:8080" },
81+
config: {
82+
KUBERNETES_FORCE_ENABLED: "true",
83+
KUBERNETES_RUN_CRD_ENABLED: "true",
84+
KUBERNETES_RUNNER_RUNTIME: "microvm",
85+
},
8286
subscription: ondemand,
8387
error: "compatibility",
8488
},
@@ -106,7 +110,7 @@ describe("worker queue selection", () => {
106110
);
107111

108112
it.each(["ondemand", "scheduled"])(
109-
"accepts %s compute restores on the native microVM Runner backend without a gateway",
113+
"accepts %s compute restores on the native microVM Runner backend",
110114
(queueClass) => {
111115
expect(() =>
112116
Env.parse({
@@ -123,11 +127,13 @@ describe("worker queue selection", () => {
123127
}
124128
);
125129

126-
it("accepts shared fresh work and compute restores on the compute backend", () => {
130+
it("accepts shared fresh work and compute restores on the native microVM Runner backend", () => {
127131
expect(() =>
128132
Env.parse({
129133
...base,
130-
COMPUTE_GATEWAY_URL: "http://localhost:8080",
134+
KUBERNETES_FORCE_ENABLED: "true",
135+
KUBERNETES_RUN_CRD_ENABLED: "true",
136+
KUBERNETES_RUNNER_RUNTIME: "microvm",
131137
TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS: JSON.stringify([
132138
{ ...ondemand, compat: "any" },
133139
{ ...restore, compat: "compute" },
@@ -178,16 +184,3 @@ describe("Env superRefine - backpressure source awareness", () => {
178184
).toThrow();
179185
});
180186
});
181-
182-
describe("Env superRefine - compute snapshots", () => {
183-
it("needs the metadata URL and workload API domain only for the gateway", () => {
184-
expect(() => Env.parse({ ...base, COMPUTE_SNAPSHOTS_ENABLED: "true" })).not.toThrow();
185-
expect(() =>
186-
Env.parse({
187-
...base,
188-
COMPUTE_SNAPSHOTS_ENABLED: "true",
189-
COMPUTE_GATEWAY_URL: "http://gateway:8080",
190-
})
191-
).toThrow(/TRIGGER_METADATA_URL[\s\S]*TRIGGER_WORKLOAD_API_DOMAIN/);
192-
});
193-
});

‎apps/supervisor/src/env.ts‎

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,9 @@ export const Env = z
180180
DOCKER_RUNNER_NETWORKS: z.string().default("host"),
181181

182182
// Compute settings
183-
COMPUTE_GATEWAY_URL: z.string().url().optional(),
184-
COMPUTE_GATEWAY_AUTH_TOKEN: z.string().optional(),
185-
COMPUTE_GATEWAY_TIMEOUT_MS: z.coerce.number().int().default(30_000),
186183
COMPUTE_SNAPSHOTS_ENABLED: BoolEnv.default(false),
187-
COMPUTE_TRACE_SPANS_ENABLED: BoolEnv.default(true),
188-
COMPUTE_TRACE_OTLP_ENDPOINT: z.string().url().optional(), // Override for span export (derived from TRIGGER_API_URL if unset)
189184
COMPUTE_SNAPSHOT_DELAY_MS: z.coerce.number().int().min(0).max(60_000).default(5_000),
190185
COMPUTE_SNAPSHOT_DISPATCH_LIMIT: z.coerce.number().int().min(1).max(100).default(10),
191-
// Instance create retries for transient placement failures (1 = no retries)
192-
COMPUTE_INSTANCE_CREATE_MAX_ATTEMPTS: z.coerce.number().int().min(1).max(10).default(3),
193-
COMPUTE_INSTANCE_CREATE_RETRY_BASE_DELAY_MS: z.coerce
194-
.number()
195-
.int()
196-
.min(0)
197-
.max(10_000)
198-
.default(250),
199186

200187
// Kubernetes settings
201188
KUBERNETES_FORCE_ENABLED: BoolEnv.default(false),
@@ -382,7 +369,7 @@ export const Env = z
382369
data.KUBERNETES_FORCE_ENABLED &&
383370
data.KUBERNETES_RUN_CRD_ENABLED &&
384371
data.KUBERNETES_RUNNER_RUNTIME === "microvm";
385-
const compatibility = data.COMPUTE_GATEWAY_URL || nativeMicrovm ? "compute" : "container";
372+
const compatibility = nativeMicrovm ? "compute" : "container";
386373

387374
for (const [index, subscription] of data.TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS.entries()) {
388375
if (subscription.compat !== "any" && subscription.compat !== compatibility) {
@@ -393,13 +380,12 @@ export const Env = z
393380
});
394381
} else if (
395382
subscription.phase === "restore" &&
396-
!(compatibility === "compute"
397-
? data.COMPUTE_GATEWAY_URL || nativeMicrovm
398-
: data.TRIGGER_CHECKPOINT_URL)
383+
compatibility === "container" &&
384+
!data.TRIGGER_CHECKPOINT_URL
399385
) {
400386
ctx.addIssue({
401387
code: z.ZodIssueCode.custom,
402-
message: `Restore subscriptions require ${compatibility === "compute" ? "COMPUTE_GATEWAY_URL" : "TRIGGER_CHECKPOINT_URL"}`,
388+
message: "Restore subscriptions require TRIGGER_CHECKPOINT_URL",
403389
path: ["TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS", index],
404390
});
405391
}
@@ -434,26 +420,6 @@ export const Env = z
434420
}
435421
}
436422
}
437-
// Only the gateway reads these for a snapshot: it builds its callback URL
438-
// from the domain and hands the metadata URL to the instance.
439-
if (data.COMPUTE_SNAPSHOTS_ENABLED && data.COMPUTE_GATEWAY_URL && !data.TRIGGER_METADATA_URL) {
440-
ctx.addIssue({
441-
code: z.ZodIssueCode.custom,
442-
message: "TRIGGER_METADATA_URL is required when COMPUTE_SNAPSHOTS_ENABLED is true",
443-
path: ["TRIGGER_METADATA_URL"],
444-
});
445-
}
446-
if (
447-
data.COMPUTE_SNAPSHOTS_ENABLED &&
448-
data.COMPUTE_GATEWAY_URL &&
449-
!data.TRIGGER_WORKLOAD_API_DOMAIN
450-
) {
451-
ctx.addIssue({
452-
code: z.ZodIssueCode.custom,
453-
message: "TRIGGER_WORKLOAD_API_DOMAIN is required when COMPUTE_SNAPSHOTS_ENABLED is true",
454-
path: ["TRIGGER_WORKLOAD_API_DOMAIN"],
455-
});
456-
}
457423
if (data.WORKLOAD_TOKEN_ENFORCEMENT !== "disabled" && !data.WORKLOAD_TOKEN_SECRET) {
458424
ctx.addIssue({
459425
code: z.ZodIssueCode.custom,
@@ -487,7 +453,6 @@ export const Env = z
487453
TRIGGER_WORKER_QUEUE_CLASS:
488454
data.TRIGGER_WORKER_QUEUE_CLASS ??
489455
(data.TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS === undefined ? "default" : undefined),
490-
COMPUTE_TRACE_OTLP_ENDPOINT: data.COMPUTE_TRACE_OTLP_ENDPOINT ?? `${data.TRIGGER_API_URL}/otel`,
491456
}));
492457

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

‎apps/supervisor/src/index.ts‎

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
} from "./workloadManager/runCrd.js";
2626
import { RestoreWatcher, type RestoreFailure } from "./services/restoreWatcher.js";
2727
import { DockerWorkloadManager } from "./workloadManager/docker.js";
28-
import { ComputeWorkloadManager } from "./workloadManager/compute.js";
2928
import {
3029
HttpServer,
3130
CheckpointClient,
@@ -41,12 +40,11 @@ import { FailedPodHandler } from "./services/failedPodHandler.js";
4140
import { DequeueDrain } from "./services/dequeueDrain.js";
4241
import { getWorkerToken } from "./workerToken.js";
4342
import { mintDeploymentToken } from "./workloadToken.js";
44-
import { OtlpTraceService } from "./services/otlpTraceService.js";
4543
import {
4644
WarmStartVerificationService,
4745
type WarmStartTimings,
4846
} from "./services/warmStartVerificationService.js";
49-
import { extractTraceparent, getRestoreRunnerId } from "./util.js";
47+
import { extractTraceparent } from "./util.js";
5048
import { Redis } from "ioredis";
5149
import { BackpressureMonitor } from "./backpressure/backpressureMonitor.js";
5250
import { RedisBackpressureSignalSource } from "./backpressure/redisBackpressureSignalSource.js";
@@ -101,8 +99,7 @@ class ManagedSupervisor {
10199
private readonly metricsServer?: HttpServer;
102100
private readonly workloadServer: WorkloadServer;
103101
private readonly workloadManager: WorkloadManager;
104-
private readonly workloadManagerBackend: "compute" | "kubernetes" | "run-crd" | "docker";
105-
private readonly computeManager?: ComputeWorkloadManager;
102+
private readonly workloadManagerBackend: "kubernetes" | "run-crd" | "docker";
106103
private readonly runCrdManager?: RunCrdWorkloadManager;
107104
private readonly restoreInformer?: RunnerRestoreInformer;
108105
private readonly restoreWatcher?: RestoreWatcher;
@@ -113,7 +110,6 @@ class ManagedSupervisor {
113110

114111
private readonly podCleaner?: PodCleaner;
115112
private readonly failedPodHandler?: FailedPodHandler;
116-
private readonly tracing?: OtlpTraceService;
117113
private readonly backpressureMonitors: BackpressureMonitor[] = [];
118114
private readonly backpressureRedis?: Redis;
119115

@@ -135,7 +131,6 @@ class ManagedSupervisor {
135131
const {
136132
TRIGGER_WORKER_TOKEN,
137133
MANAGED_WORKER_SECRET,
138-
COMPUTE_GATEWAY_AUTH_TOKEN,
139134
DOCKER_REGISTRY_PASSWORD,
140135
TRIGGER_DEQUEUE_BACKPRESSURE_REDIS_PASSWORD,
141136
WORKLOAD_TOKEN_SECRET,
@@ -172,48 +167,7 @@ class ManagedSupervisor {
172167
: new DockerResourceMonitor(new Docker())
173168
: new NoopResourceMonitor();
174169

175-
if (env.COMPUTE_GATEWAY_URL) {
176-
if (!env.TRIGGER_WORKLOAD_API_DOMAIN) {
177-
throw new Error("TRIGGER_WORKLOAD_API_DOMAIN is not set, cannot create compute manager");
178-
}
179-
180-
const callbackUrl = `${env.TRIGGER_WORKLOAD_API_PROTOCOL}://${env.TRIGGER_WORKLOAD_API_DOMAIN}:${env.TRIGGER_WORKLOAD_API_PORT_EXTERNAL}/api/v1/compute/snapshot-complete`;
181-
182-
if (env.COMPUTE_TRACE_SPANS_ENABLED) {
183-
this.tracing = new OtlpTraceService({
184-
endpointUrl: env.COMPUTE_TRACE_OTLP_ENDPOINT,
185-
});
186-
}
187-
188-
const computeManager = new ComputeWorkloadManager({
189-
...workloadManagerOptions,
190-
gateway: {
191-
url: env.COMPUTE_GATEWAY_URL,
192-
authToken: env.COMPUTE_GATEWAY_AUTH_TOKEN,
193-
timeoutMs: env.COMPUTE_GATEWAY_TIMEOUT_MS,
194-
},
195-
snapshots: {
196-
enabled: env.COMPUTE_SNAPSHOTS_ENABLED,
197-
delayMs: env.COMPUTE_SNAPSHOT_DELAY_MS,
198-
dispatchLimit: env.COMPUTE_SNAPSHOT_DISPATCH_LIMIT,
199-
callbackUrl,
200-
},
201-
tracing: this.tracing,
202-
runner: {
203-
instanceName: env.TRIGGER_WORKER_INSTANCE_NAME,
204-
otelEndpoint: env.OTEL_EXPORTER_OTLP_ENDPOINT,
205-
prettyLogs: env.RUNNER_PRETTY_LOGS,
206-
sendRunDebugLogs: env.SEND_RUN_DEBUG_LOGS,
207-
},
208-
createRetry: {
209-
maxAttempts: env.COMPUTE_INSTANCE_CREATE_MAX_ATTEMPTS,
210-
baseDelayMs: env.COMPUTE_INSTANCE_CREATE_RETRY_BASE_DELAY_MS,
211-
},
212-
});
213-
this.computeManager = computeManager;
214-
this.workloadManager = computeManager;
215-
this.workloadManagerBackend = "compute";
216-
} else if (this.isKubernetes && env.KUBERNETES_RUN_CRD_ENABLED) {
170+
if (this.isKubernetes && env.KUBERNETES_RUN_CRD_ENABLED) {
217171
// Only a process that dequeues creates resumes, and only the microvm lane restores.
218172
if (
219173
env.KUBERNETES_RUNNER_RESTORE_INFORMER_ENABLED &&
@@ -522,66 +476,10 @@ class ManagedSupervisor {
522476

523477
const { checkpoint, ...rest } = message;
524478

525-
// Register trace context early so snapshot spans work for all paths
526-
// (cold create, restore, warm start). Re-registration on restore is safe
527-
// since dequeue always provides fresh context.
528-
if (this.computeManager?.traceSpansEnabled && traceparent) {
529-
this.workloadServer.registerRunTraceContext(message.run.friendlyId, {
530-
traceparent,
531-
envId: message.environment.id,
532-
orgId: message.organization.id,
533-
projectId: message.project.id,
534-
});
535-
}
536-
537479
if (checkpoint) {
538480
setExtra(fromContext(), "path_taken", "restore");
539481
this.logger.debug("Restoring run", { runId: message.run.id });
540482

541-
if (this.computeManager) {
542-
const restoreStart = performance.now();
543-
try {
544-
const runnerId = getRestoreRunnerId(message.run.friendlyId, checkpoint.id);
545-
546-
const didRestore = await this.computeManager.restore({
547-
snapshotId: checkpoint.location,
548-
runnerId,
549-
runFriendlyId: message.run.friendlyId,
550-
snapshotFriendlyId: message.snapshot.friendlyId,
551-
machine: message.run.machine,
552-
traceContext: message.run.traceContext,
553-
envId: message.environment.id,
554-
orgId: message.organization.id,
555-
projectId: message.project.id,
556-
hasPrivateLink: message.organization.hasPrivateLink,
557-
dequeuedAt: message.dequeuedAt,
558-
});
559-
recordPhaseSince("restore", restoreStart, undefined);
560-
setExtra(fromContext(), "did_restore", didRestore);
561-
562-
if (didRestore) {
563-
this.logger.debug("Compute restore successful", {
564-
runId: message.run.id,
565-
runnerId,
566-
});
567-
} else {
568-
this.logger.error("Compute restore failed", {
569-
runId: message.run.id,
570-
runnerId,
571-
});
572-
}
573-
} catch (error) {
574-
recordPhaseSince(
575-
"restore",
576-
restoreStart,
577-
error instanceof Error ? error : new Error(String(error))
578-
);
579-
this.logger.error("Failed to restore run (compute)", { error });
580-
}
581-
582-
return;
583-
}
584-
585483
if (this.runCrdManager?.restores(checkpoint)) {
586484
await this.restoreRunner(this.runCrdManager, message, checkpoint);
587485
return;
@@ -673,10 +571,7 @@ class ManagedSupervisor {
673571
host: env.TRIGGER_WORKLOAD_API_HOST_INTERNAL,
674572
workerClient: this.workerSession.httpClient,
675573
checkpointClient: this.checkpointClient,
676-
computeManager: this.computeManager,
677574
runnerSnapshotter: this.runCrdManager,
678-
tracing: this.tracing,
679-
snapshotCallbackSecret: workerToken,
680575
wideEventOpts: this.wideEventOpts,
681576
wideEventsNoisyRoutes: this.wideEventsNoisyRoutes,
682577
});

0 commit comments

Comments
 (0)