fix(runner): keep session pvc mount provider independent (#239)
This commit is contained in:
+1
-1
@@ -1542,7 +1542,7 @@ async function renderRunnerJob(args: ParsedArgs): Promise<JsonRecord> {
|
|||||||
const session = await client(args).get(`/api/v1/sessions/${encodeURIComponent(run.sessionRef.sessionId)}`) as { storageKind?: string; storagePvcName?: string; storageNamespace?: string; codexRolloutSubdir?: string };
|
const session = await client(args).get(`/api/v1/sessions/${encodeURIComponent(run.sessionRef.sessionId)}`) as { storageKind?: string; storagePvcName?: string; storageNamespace?: string; codexRolloutSubdir?: string };
|
||||||
if (session?.storageKind === "pvc" && session.storagePvcName) {
|
if (session?.storageKind === "pvc" && session.storagePvcName) {
|
||||||
const subdir = session.codexRolloutSubdir ?? "sessions";
|
const subdir = session.codexRolloutSubdir ?? "sessions";
|
||||||
sessionPvc = { pvcName: session.storagePvcName, namespace: session.storageNamespace ?? "agentrun-v01", mountPath: `/home/agentrun/.codex-${run.backendProfile}/${subdir}`, codexRolloutSubdir: subdir };
|
sessionPvc = { pvcName: session.storagePvcName, namespace: session.storageNamespace ?? "agentrun-v01", mountPath: `/home/agentrun/.agentrun-sessions/${subdir}`, codexRolloutSubdir: subdir };
|
||||||
}
|
}
|
||||||
} catch { /* session not found, skip */ }
|
} catch { /* session not found, skip */ }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ export async function createKubernetesRunnerJob(options: { store: AgentRunStore;
|
|||||||
const pvcName = refreshed?.storagePvcName ?? ensured.pvcName;
|
const pvcName = refreshed?.storagePvcName ?? ensured.pvcName;
|
||||||
if (!pvcName) throw new AgentRunError("infra-failed", `session ${run.sessionRef.sessionId} PVC was not resolved for runner job`, { httpStatus: 502 });
|
if (!pvcName) throw new AgentRunError("infra-failed", `session ${run.sessionRef.sessionId} PVC was not resolved for runner job`, { httpStatus: 502 });
|
||||||
const subdir = refreshed?.codexRolloutSubdir ?? ensured.codexRolloutSubdir ?? "sessions";
|
const subdir = refreshed?.codexRolloutSubdir ?? ensured.codexRolloutSubdir ?? "sessions";
|
||||||
const mountPath = `/home/agentrun/.codex-${run.backendProfile}/${subdir}`;
|
const mountPath = `/home/agentrun/.agentrun-sessions/${subdir}`;
|
||||||
const workspacePath = `${mountPath}/agentrun-workspace`;
|
const workspacePath = `${mountPath}/agentrun-workspace`;
|
||||||
sessionPvc = { pvcName, namespace: refreshed?.storageNamespace ?? ensured.namespace ?? namespace, mountPath, codexRolloutSubdir: subdir, workspacePath };
|
sessionPvc = { pvcName, namespace: refreshed?.storageNamespace ?? ensured.namespace ?? namespace, mountPath, codexRolloutSubdir: subdir, workspacePath };
|
||||||
sessionPvcSummary = {
|
sessionPvcSummary = {
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ process.exit(1);
|
|||||||
commandId: "cmd-selftest-session-pvc",
|
commandId: "cmd-selftest-session-pvc",
|
||||||
managerUrl: server.baseUrl,
|
managerUrl: server.baseUrl,
|
||||||
image: "127.0.0.1:5000/agentrun/agentrun-mgr-env:self-test",
|
image: "127.0.0.1:5000/agentrun/agentrun-mgr-env:self-test",
|
||||||
sessionPvc: { pvcName: "agentrun-v01-session-sess-selftest-runner-001", namespace: "agentrun-v01", mountPath: "/home/agentrun/.codex-codex/sessions", codexRolloutSubdir: "sessions" },
|
sessionPvc: { pvcName: "agentrun-v01-session-sess-selftest-runner-001", namespace: "agentrun-v01", mountPath: "/home/agentrun/.agentrun-sessions/sessions", codexRolloutSubdir: "sessions" },
|
||||||
});
|
});
|
||||||
const sessionPvcManifest = sessionPvcRendered.manifest as JsonRecord;
|
const sessionPvcManifest = sessionPvcRendered.manifest as JsonRecord;
|
||||||
const sessionPvcSpec = sessionPvcManifest.spec as JsonRecord;
|
const sessionPvcSpec = sessionPvcManifest.spec as JsonRecord;
|
||||||
@@ -469,13 +469,13 @@ process.exit(1);
|
|||||||
const sessionPvcContainers = Array.isArray(sessionPvcPodSpec.containers) ? sessionPvcPodSpec.containers as JsonRecord[] : [];
|
const sessionPvcContainers = Array.isArray(sessionPvcPodSpec.containers) ? sessionPvcPodSpec.containers as JsonRecord[] : [];
|
||||||
const sessionPvcMounts = Array.isArray(sessionPvcContainers[0]?.volumeMounts) ? sessionPvcContainers[0].volumeMounts as JsonRecord[] : [];
|
const sessionPvcMounts = Array.isArray(sessionPvcContainers[0]?.volumeMounts) ? sessionPvcContainers[0].volumeMounts as JsonRecord[] : [];
|
||||||
const sessionPvcVols = Array.isArray(sessionPvcPodSpec.volumes) ? sessionPvcPodSpec.volumes as JsonRecord[] : [];
|
const sessionPvcVols = Array.isArray(sessionPvcPodSpec.volumes) ? sessionPvcPodSpec.volumes as JsonRecord[] : [];
|
||||||
assert.ok(sessionPvcMounts.some((m) => m.name === "agentrun-sessions" && m.mountPath === "/home/agentrun/.codex-codex/sessions" && m.readOnly === false), "session pvc volume mount must be present");
|
assert.ok(sessionPvcMounts.some((m) => m.name === "agentrun-sessions" && m.mountPath === "/home/agentrun/.agentrun-sessions/sessions" && m.readOnly === false), "session pvc volume mount must be present");
|
||||||
assert.ok(sessionPvcVols.some((v) => typeof v === "object" && v !== null && (v as JsonRecord).persistentVolumeClaim !== undefined && ((v as JsonRecord).persistentVolumeClaim as JsonRecord).claimName === "agentrun-v01-session-sess-selftest-runner-001"), "session pvc volume must reference the per-session PVC");
|
assert.ok(sessionPvcVols.some((v) => typeof v === "object" && v !== null && (v as JsonRecord).persistentVolumeClaim !== undefined && ((v as JsonRecord).persistentVolumeClaim as JsonRecord).claimName === "agentrun-v01-session-sess-selftest-runner-001"), "session pvc volume must reference the per-session PVC");
|
||||||
const sessionPvcEnv = Array.isArray(sessionPvcContainers[0]?.env) ? sessionPvcContainers[0].env as JsonRecord[] : [];
|
const sessionPvcEnv = Array.isArray(sessionPvcContainers[0]?.env) ? sessionPvcContainers[0].env as JsonRecord[] : [];
|
||||||
const envMap = new Map(sessionPvcEnv.map((e) => [String(e.name), String(e.value)]));
|
const envMap = new Map(sessionPvcEnv.map((e) => [String(e.name), String(e.value)]));
|
||||||
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_NAME"), "agentrun-v01-session-sess-selftest-runner-001");
|
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_NAME"), "agentrun-v01-session-sess-selftest-runner-001");
|
||||||
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_NAMESPACE"), "agentrun-v01");
|
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_NAMESPACE"), "agentrun-v01");
|
||||||
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_MOUNT_PATH"), "/home/agentrun/.codex-codex/sessions");
|
assert.equal(envMap.get("AGENTRUN_SESSION_PVC_MOUNT_PATH"), "/home/agentrun/.agentrun-sessions/sessions");
|
||||||
assert.equal(envMap.get("AGENTRUN_CODEX_ROLLOUT_SUBDIR"), "sessions");
|
assert.equal(envMap.get("AGENTRUN_CODEX_ROLLOUT_SUBDIR"), "sessions");
|
||||||
return { name: "runner-k8s-job", tests: ["runner-k8s-job-dry-run", "runner-k8s-job-codex-shell-sandbox-env", "runner-k8s-job-g14-egress-proxy-env", "runner-k8s-job-bounded-git-transport-env", "runner-k8s-job-deepseek-profile-dry-run", "runner-k8s-job-minimax-m3-profile-dry-run", "runner-k8s-job-dsflash-go-profile-dry-run", "runner-k8s-job-dsflash-go-legacy-secretref-normalized", "runner-k8s-job-create-api", "runner-k8s-job-retention-ttl", "runner-job-transient-env", "runner-job-transient-env-secretref", "runner-job-tool-credential-env", "runner-job-unidesk-ssh-tool-credential-env", "runner-job-tool-credential-volume", "runner-job-unidesk-ssh-endpoint-auto-env", "runner-job-unidesk-ssh-transient-env-denied", "runner-job-pre-create-retention", "runner-job-pre-create-retention-protects-stale-active", "runner-k8s-job-session-pvc-volume-and-env"] };
|
return { name: "runner-k8s-job", tests: ["runner-k8s-job-dry-run", "runner-k8s-job-codex-shell-sandbox-env", "runner-k8s-job-g14-egress-proxy-env", "runner-k8s-job-bounded-git-transport-env", "runner-k8s-job-deepseek-profile-dry-run", "runner-k8s-job-minimax-m3-profile-dry-run", "runner-k8s-job-dsflash-go-profile-dry-run", "runner-k8s-job-dsflash-go-legacy-secretref-normalized", "runner-k8s-job-create-api", "runner-k8s-job-retention-ttl", "runner-job-transient-env", "runner-job-transient-env-secretref", "runner-job-tool-credential-env", "runner-job-unidesk-ssh-tool-credential-env", "runner-job-tool-credential-volume", "runner-job-unidesk-ssh-endpoint-auto-env", "runner-job-unidesk-ssh-transient-env-denied", "runner-job-pre-create-retention", "runner-job-pre-create-retention-protects-stale-active", "runner-k8s-job-session-pvc-volume-and-env"] };
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ async function runSessionStorageMountedCase(options: { client: ManagerClient; ma
|
|||||||
|
|
||||||
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-mounted",
|
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-mounted",
|
||||||
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
||||||
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.codex-codex/sessions",
|
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.agentrun-sessions/sessions",
|
||||||
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
||||||
},
|
},
|
||||||
oneShot: true,
|
oneShot: true,
|
||||||
@@ -606,7 +606,7 @@ async function runSessionStorageMountedCase(options: { client: ManagerClient; ma
|
|||||||
const payload = eventPayload(mounted);
|
const payload = eventPayload(mounted);
|
||||||
assert.equal(payload.pvcName, "agentrun-v01-session-selftest-mounted");
|
assert.equal(payload.pvcName, "agentrun-v01-session-selftest-mounted");
|
||||||
assert.equal(payload.pvcNamespace, "agentrun-v01");
|
assert.equal(payload.pvcNamespace, "agentrun-v01");
|
||||||
assert.equal(payload.mountPath, "/home/agentrun/.codex-codex/sessions");
|
assert.equal(payload.mountPath, "/home/agentrun/.agentrun-sessions/sessions");
|
||||||
assert.equal(payload.codexRolloutSubdir, "sessions");
|
assert.equal(payload.codexRolloutSubdir, "sessions");
|
||||||
assert.equal(payload.valuesPrinted, false);
|
assert.equal(payload.valuesPrinted, false);
|
||||||
}
|
}
|
||||||
@@ -625,7 +625,7 @@ async function runSessionStorageEvictedCase(options: { client: ManagerClient; ma
|
|||||||
AGENTRUN_FAKE_CODEX_MODE: "resume-no-rollout",
|
AGENTRUN_FAKE_CODEX_MODE: "resume-no-rollout",
|
||||||
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-evicted",
|
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-evicted",
|
||||||
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
||||||
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.codex-codex/sessions",
|
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.agentrun-sessions/sessions",
|
||||||
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
||||||
},
|
},
|
||||||
oneShot: true,
|
oneShot: true,
|
||||||
@@ -647,7 +647,7 @@ async function runSessionStorageSubdirCase(options: { client: ManagerClient; man
|
|||||||
|
|
||||||
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-subdir",
|
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-subdir",
|
||||||
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
||||||
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.codex-deepseek/custom",
|
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.agentrun-sessions/custom",
|
||||||
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "custom",
|
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "custom",
|
||||||
},
|
},
|
||||||
oneShot: true,
|
oneShot: true,
|
||||||
@@ -657,7 +657,7 @@ async function runSessionStorageSubdirCase(options: { client: ManagerClient; man
|
|||||||
assert.ok(mounted, "storage-mounted event must fire for custom subdir");
|
assert.ok(mounted, "storage-mounted event must fire for custom subdir");
|
||||||
const payload = eventPayload(mounted);
|
const payload = eventPayload(mounted);
|
||||||
assert.equal(payload.codexRolloutSubdir, "custom", "AGENTRUN_CODEX_ROLLOUT_SUBDIR must be observed in the storage-mounted event");
|
assert.equal(payload.codexRolloutSubdir, "custom", "AGENTRUN_CODEX_ROLLOUT_SUBDIR must be observed in the storage-mounted event");
|
||||||
assert.equal(payload.mountPath, "/home/agentrun/.codex-deepseek/custom", "mount path must use the rollout subdir suffix");
|
assert.equal(payload.mountPath, "/home/agentrun/.agentrun-sessions/custom", "mount path must use the rollout subdir suffix");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runSessionStorageNoSecretLeakCase(options: { client: ManagerClient; managerUrl: string; context: SelfTestContext }): Promise<void> {
|
async function runSessionStorageNoSecretLeakCase(options: { client: ManagerClient; managerUrl: string; context: SelfTestContext }): Promise<void> {
|
||||||
@@ -673,7 +673,7 @@ async function runSessionStorageNoSecretLeakCase(options: { client: ManagerClien
|
|||||||
|
|
||||||
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-leak",
|
AGENTRUN_SESSION_PVC_NAME: "agentrun-v01-session-selftest-leak",
|
||||||
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
AGENTRUN_SESSION_PVC_NAMESPACE: "agentrun-v01",
|
||||||
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.codex-codex/sessions",
|
AGENTRUN_SESSION_PVC_MOUNT_PATH: "/home/agentrun/.agentrun-sessions/sessions",
|
||||||
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
AGENTRUN_CODEX_ROLLOUT_SUBDIR: "sessions",
|
||||||
},
|
},
|
||||||
oneShot: true,
|
oneShot: true,
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ process.exit(1);
|
|||||||
const dispatchManifest = JSON.parse(await readFile(createdManifest, "utf8")) as JsonRecord;
|
const dispatchManifest = JSON.parse(await readFile(createdManifest, "utf8")) as JsonRecord;
|
||||||
assert.ok(JSON.stringify(dispatchManifest).includes(dispatched.run.id));
|
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_NAME"), "agentrun-v01-session-sess-queue-q2-dispatch-selftest");
|
||||||
assert.equal(runnerEnvValue(dispatchManifest, "AGENTRUN_SESSION_PVC_MOUNT_PATH"), "/home/agentrun/.codex-codex/sessions");
|
assert.equal(runnerEnvValue(dispatchManifest, "AGENTRUN_SESSION_PVC_MOUNT_PATH"), "/home/agentrun/.agentrun-sessions/sessions");
|
||||||
assert.ok(runnerVolumeMount(dispatchManifest, "agentrun-sessions", "/home/agentrun/.codex-codex/sessions"), "queue dispatch must mount session PVC for same-session resume");
|
assert.ok(runnerVolumeMount(dispatchManifest, "agentrun-sessions", "/home/agentrun/.agentrun-sessions/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");
|
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", {
|
const unideskCreated = await client.post("/api/v1/queue/tasks", {
|
||||||
|
|||||||
Reference in New Issue
Block a user