Skip to content

Commit f9fd2b8

Browse files
1stvampTrigger.dev RepoOps
authored andcommitted
fix(supervisor): allow native microVM restore subscriptions
Supervisor: allow compute restore subscriptions on the native Kubernetes microVM backend without a compute gateway URL. Mono-RevId: e3ca49a622dd64b7aed290de0ea7528d423ace7b
1 parent 6f671f1 commit f9fd2b8

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ describe("worker queue selection", () => {
8686
{
8787
config: {
8888
KUBERNETES_FORCE_ENABLED: "true",
89-
KUBERNETES_RUN_CRD_ENABLED: "true",
89+
KUBERNETES_RUN_CRD_ENABLED: "false",
9090
KUBERNETES_RUNNER_RUNTIME: "microvm",
9191
},
9292
subscription: { ...restore, compat: "compute" },
93-
error: "COMPUTE_GATEWAY_URL",
93+
error: "compatibility",
9494
},
9595
])(
9696
"rejects incompatible or unsupported subscriptions: $error",
@@ -105,6 +105,24 @@ describe("worker queue selection", () => {
105105
}
106106
);
107107

108+
it.each(["ondemand", "scheduled"])(
109+
"accepts %s compute restores on the native microVM Runner backend without a gateway",
110+
(queueClass) => {
111+
expect(() =>
112+
Env.parse({
113+
...base,
114+
KUBERNETES_FORCE_ENABLED: "true",
115+
KUBERNETES_RUN_CRD_ENABLED: "true",
116+
KUBERNETES_RUNNER_RUNTIME: "microvm",
117+
TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS: JSON.stringify([
118+
{ ...ondemand, class: queueClass, compat: "compute" },
119+
{ ...restore, class: queueClass, compat: "compute" },
120+
]),
121+
})
122+
).not.toThrow();
123+
}
124+
);
125+
108126
it("accepts shared fresh work and compute restores on the compute backend", () => {
109127
expect(() =>
110128
Env.parse({

‎apps/supervisor/src/env.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,11 @@ export const Env = z
378378
});
379379
}
380380

381-
const compatibility =
382-
data.COMPUTE_GATEWAY_URL ||
383-
(data.KUBERNETES_FORCE_ENABLED &&
384-
data.KUBERNETES_RUN_CRD_ENABLED &&
385-
data.KUBERNETES_RUNNER_RUNTIME === "microvm")
386-
? "compute"
387-
: "container";
381+
const nativeMicrovm =
382+
data.KUBERNETES_FORCE_ENABLED &&
383+
data.KUBERNETES_RUN_CRD_ENABLED &&
384+
data.KUBERNETES_RUNNER_RUNTIME === "microvm";
385+
const compatibility = data.COMPUTE_GATEWAY_URL || nativeMicrovm ? "compute" : "container";
388386

389387
for (const [index, subscription] of data.TRIGGER_WORKER_QUEUE_SUBSCRIPTIONS.entries()) {
390388
if (subscription.compat !== "any" && subscription.compat !== compatibility) {
@@ -395,7 +393,9 @@ export const Env = z
395393
});
396394
} else if (
397395
subscription.phase === "restore" &&
398-
!(compatibility === "compute" ? data.COMPUTE_GATEWAY_URL : data.TRIGGER_CHECKPOINT_URL)
396+
!(compatibility === "compute"
397+
? data.COMPUTE_GATEWAY_URL || nativeMicrovm
398+
: data.TRIGGER_CHECKPOINT_URL)
399399
) {
400400
ctx.addIssue({
401401
code: z.ZodIssueCode.custom,

0 commit comments

Comments
 (0)