Skip to content

Commit 1483d02

Browse files
carderneTrigger.dev RepoOps
authored andcommitted
fix(supervisor): place microVM workloads without waiting for Pod status
Mono-RevId: f9d026c4a3ed7c3f050b7e1980398344bf4d0145
1 parent 145b71b commit 1483d02

6 files changed

Lines changed: 208 additions & 259 deletions

File tree

‎apps/supervisor/src/services/fixtures/secretProxy.ts‎

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const K3S_IMAGE =
2727
"rancher/k3s:v1.32.4-k3s1@sha256:1b71c68b063364bab469452eb9cc27edcb2767273f1aca5582db3586a3927483";
2828
const PAUSE_IMAGE =
2929
"rancher/mirrored-pause:3.6@sha256:74c4244427b7312c5b901fe0f67cbc53683d06f4f24c6faee65d4182bf0fa893";
30-
// Never pullable, so its container stays waiting: a Pod with an IP and no running container.
31-
const UNPULLABLE_IMAGE = "registry.invalid/secret-proxy/never-pulled:0";
3230
const STARTUP_TIMEOUT_MS = 180_000;
3331
const INTERCEPTOR_GRACE_MS = 5_000;
3432
const INTERCEPTOR_EXIT_TIMEOUT_MS = 10_000;
@@ -110,6 +108,8 @@ function runnerName(runId: string, attempt?: number, checkpoint?: string) {
110108
export type FixtureAllocation = {
111109
allocationId: string;
112110
guestId: string;
111+
podUid?: string;
112+
podIp?: string;
113113
runId: string;
114114
attempt: number;
115115
};
@@ -172,7 +172,13 @@ export class AllocationOwner {
172172
}
173173

174174
async register(allocation: FixtureAllocation, listen = "127.0.0.1:0"): Promise<string> {
175-
const response = await this.command({ op: "register", ...allocation, listen });
175+
const { podUid, podIp, ...registration } = allocation;
176+
const response = await this.command({
177+
op: "register",
178+
...registration,
179+
listen,
180+
env: { TRIGGER_POD_UID: podUid, TRIGGER_POD_IP: podIp },
181+
});
176182
if (typeof response.listen !== "string") throw new Error("Missing allocation listener address");
177183
return response.listen;
178184
}
@@ -417,18 +423,26 @@ export class SecretProxyFixture {
417423
);
418424
}
419425

420-
/**
421-
* A Runner and Pod whose container never starts (unpullable image), so the Pod has an IP but
422-
* no running container: the state a guest can call start in before kubelet publishes status.
423-
*/
426+
/** A missing required volume keeps kubelet from creating the sandbox. */
424427
async pendingPlacement(runId: string, claims = deploymentClaims): Promise<SecretProxyCaller> {
425428
const name = runnerName(runId);
426-
await this.createPlacement(name, runId, claims, UNPULLABLE_IMAGE);
427-
const pod = await waitFor(async () => {
428-
const current = await this.core.readNamespacedPod({ name, namespace: this.namespace });
429-
return current.status?.podIP ? current : undefined;
430-
}, "pending placement Pod IP");
431-
return { runId, runnerId: name, claims, sourceIp: pod.status!.podIP! };
429+
await this.createPlacement(name, runId, claims, PAUSE_IMAGE, {
430+
holdSandbox: true,
431+
});
432+
const pod = await this.core.readNamespacedPod({
433+
name,
434+
namespace: this.namespace,
435+
});
436+
const ip = "192.0.2.10";
437+
this.placementsByRunner.set(name, {
438+
allocationId: randomUUID(),
439+
guestId: randomUUID(),
440+
runId,
441+
attempt: 1,
442+
podUid: pod.metadata!.uid!,
443+
podIp: ip,
444+
});
445+
return { runId, runnerId: name, claims, sourceIp: ip };
432446
}
433447

434448
private async createPlacement(
@@ -440,7 +454,13 @@ export class SecretProxyFixture {
440454
singleUse,
441455
checkpoint,
442456
sourceIp,
443-
}: { singleUse?: boolean; checkpoint?: string; sourceIp?: string } = {}
457+
holdSandbox,
458+
}: {
459+
singleUse?: boolean;
460+
checkpoint?: string;
461+
sourceIp?: string;
462+
holdSandbox?: boolean;
463+
} = {}
444464
) {
445465
const runner = (await this.custom.createNamespacedCustomObject({
446466
group: "compute.trigger.dev",
@@ -491,11 +511,26 @@ export class SecretProxyFixture {
491511
},
492512
spec: {
493513
nodeName: this.nodeName,
514+
restartPolicy: "Never",
515+
volumes: holdSandbox
516+
? [{ name: "missing", configMap: { name: "absent-configmap" } }]
517+
: undefined,
494518
terminationGracePeriodSeconds: 0,
495519
containers: [
496520
{
497521
name: containerName,
498522
image,
523+
env: [
524+
{
525+
name: "TRIGGER_POD_UID",
526+
valueFrom: { fieldRef: { fieldPath: "metadata.uid" } },
527+
},
528+
{
529+
name: "TRIGGER_POD_IP",
530+
valueFrom: { fieldRef: { fieldPath: "status.podIP" } },
531+
},
532+
],
533+
volumeMounts: holdSandbox ? [{ name: "missing", mountPath: "/missing" }] : undefined,
499534
resources: { requests: { cpu: "1m", memory: "2Mi" } },
500535
},
501536
],
@@ -574,6 +609,8 @@ export class SecretProxyFixture {
574609
const pod = pods.get(runnerId)!;
575610
this.placementsByRunner.set(runnerId, {
576611
allocationId: randomUUID(),
612+
podUid: pod.metadata!.uid!,
613+
podIp: pod.status!.podIP!,
577614
guestId: pod.status!.containerStatuses![0]!.containerID!.replace(/^containerd:\/\//, ""),
578615
runId,
579616
// A restored allocation has no attempt until its first binding.

0 commit comments

Comments
 (0)