fix: provision session pvc before runner dispatch (#168)
Co-authored-by: AgentRun Codex <agentrun-codex@users.noreply.github.com>
This commit is contained in:
@@ -152,6 +152,10 @@ if (args[0] === "create") {
|
||||
console.log(JSON.stringify({ apiVersion: manifest.apiVersion, kind: manifest.kind, metadata: { uid, resourceVersion: "1", name: manifest.metadata.name, namespace: manifest.metadata.namespace } }));
|
||||
process.exit(0);
|
||||
}
|
||||
if (args[0] === "get" && args[1] === "pvc") {
|
||||
console.error("Error from server (NotFound): persistentvolumeclaims " + args[2] + " not found");
|
||||
process.exit(1);
|
||||
}
|
||||
if (args[0] === "patch" && args[1] === "secret") {
|
||||
await Bun.write(${JSON.stringify(patchedTransientEnvSecret)}, JSON.stringify({ args }, null, 2));
|
||||
console.log(JSON.stringify({ apiVersion: "v1", kind: "Secret", metadata: { uid: "secret-uid-selftest", resourceVersion: "2", name: args[2], namespace: args[4] } }));
|
||||
|
||||
@@ -26,6 +26,10 @@ if (args[0] === "create") {
|
||||
console.log(JSON.stringify({ apiVersion: manifest.apiVersion, kind: manifest.kind, metadata: { uid, resourceVersion: "1", name: manifest.metadata.name, namespace: manifest.metadata.namespace } }));
|
||||
process.exit(0);
|
||||
}
|
||||
if (args[0] === "get" && args[1] === "pvc") {
|
||||
console.error("Error from server (NotFound): persistentvolumeclaims " + args[2] + " not found");
|
||||
process.exit(1);
|
||||
}
|
||||
if (args[0] === "patch" && args[1] === "secret") {
|
||||
console.log(JSON.stringify({ apiVersion: "v1", kind: "Secret", metadata: { uid: "secret-uid-queue-q2", resourceVersion: "2", name: args[2], namespace: args[4] } }));
|
||||
process.exit(0);
|
||||
@@ -168,6 +172,10 @@ process.exit(1);
|
||||
assert.equal(refreshed.latestAttempt?.sessionPath, "/api/v1/sessions/sess_queue_q2_dispatch_selftest");
|
||||
const dispatchManifest = JSON.parse(await readFile(createdManifest, "utf8")) as JsonRecord;
|
||||
assert.ok(JSON.stringify(dispatchManifest).includes(dispatched.run.id));
|
||||
assert.equal(runnerEnvValue(dispatchManifest, "AGENTRUN_SESSION_PVC_NAME"), "agentrun-v01-session-sess-queue-q2-dispatch-selftest");
|
||||
assert.equal(runnerEnvValue(dispatchManifest, "AGENTRUN_SESSION_PVC_MOUNT_PATH"), "/home/agentrun/.codex-codex/sessions");
|
||||
assert.ok(runnerVolumeMount(dispatchManifest, "agentrun-sessions", "/home/agentrun/.codex-codex/sessions"), "queue dispatch must mount session PVC for same-session resume");
|
||||
assert.ok(runnerPersistentVolumeClaim(dispatchManifest, "agentrun-sessions", "agentrun-v01-session-sess-queue-q2-dispatch-selftest"), "queue dispatch PVC volume must reference per-session claim");
|
||||
|
||||
const unideskCreated = await client.post("/api/v1/queue/tasks", {
|
||||
tenantId: "unidesk",
|
||||
@@ -325,3 +333,20 @@ function runnerEnvValue(manifest: JsonRecord, name: string): unknown {
|
||||
if (item.valueFrom) return "secretRef";
|
||||
return item.value;
|
||||
}
|
||||
|
||||
function runnerVolumeMount(manifest: JsonRecord, volumeName: string, mountPath: string): boolean {
|
||||
const spec = manifest.spec as JsonRecord;
|
||||
const template = spec.template as JsonRecord;
|
||||
const podSpec = template.spec as JsonRecord;
|
||||
const containers = podSpec.containers as JsonRecord[];
|
||||
const mounts = containers[0]?.volumeMounts as JsonRecord[];
|
||||
return Array.isArray(mounts) && mounts.some((mount) => mount.name === volumeName && mount.mountPath === mountPath && mount.readOnly === false);
|
||||
}
|
||||
|
||||
function runnerPersistentVolumeClaim(manifest: JsonRecord, volumeName: string, claimName: string): boolean {
|
||||
const spec = manifest.spec as JsonRecord;
|
||||
const template = spec.template as JsonRecord;
|
||||
const podSpec = template.spec as JsonRecord;
|
||||
const volumes = podSpec.volumes as JsonRecord[];
|
||||
return Array.isArray(volumes) && volumes.some((volume) => volume.name === volumeName && ((volume.persistentVolumeClaim as JsonRecord | undefined)?.claimName) === claimName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user