From 0dfe709fd426159c7da6bcf7e41850c1f5fcf4b2 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 3 Jun 2026 21:16:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(v0.1):=20CLI=20runner=20job=20--dry-run=20?= =?UTF-8?q?=E4=B9=9F=E6=9F=A5=20session=20=E5=8A=A0=20sessionPvc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 CLI runner job --dry-run 直接调 renderRunnerJobDryRun 不经 mgr, 所以 kubernetes-runner-job.ts 里的 sessionPvc 查找逻辑被绕过, dry-run manifest 不含 agentrun-sessions volume。 修复:dry-run 路径先 GET /api/v1/sessions 查 storageKind=pvc + storagePvcName, 自己构造 sessionPvc 传给 renderRunnerJobDryRun,dry-run 输出 与 mgr 真实创建 runner Job 的 manifest 一致。 --- scripts/src/cli.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/src/cli.ts b/scripts/src/cli.ts index 9ffc077..fed36cd 100644 --- a/scripts/src/cli.ts +++ b/scripts/src/cli.ts @@ -8,6 +8,7 @@ import { MemoryAgentRunStore } from "../../src/mgr/store.js"; import { ManagerClient } from "../../src/mgr/client.js"; import { runOnce } from "../../src/runner/run-once.js"; import { renderRunnerJobDryRun } from "../../src/runner/k8s-job.js"; +import type { RunnerSessionPvcOptions } from "../../src/runner/k8s-job.js"; import { renderCodexProviderSecretPlan } from "./secret-render.js"; import type { BackendProfile, CommandRecord, JsonRecord, JsonValue, RunRecord, SessionSummary } from "../../src/common/types.js"; import { AgentRunError, errorToJson } from "../../src/common/errors.js"; @@ -341,12 +342,23 @@ async function renderRunnerJob(args: ParsedArgs): Promise { } if (!image) throw new AgentRunError("schema-invalid", "runner job --dry-run requires --image", { httpStatus: 2 }); const run = await client(args).get(`/api/v1/runs/${encodeURIComponent(runId)}`) as RunRecord; + let sessionPvc: RunnerSessionPvcOptions | undefined; + if (run.sessionRef?.sessionId) { + try { + 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) { + const subdir = session.codexRolloutSubdir ?? "sessions"; + sessionPvc = { pvcName: session.storagePvcName, namespace: session.storageNamespace ?? "agentrun-v01", mountPath: `/home/agentrun/.codex-${run.backendProfile}/${subdir}`, codexRolloutSubdir: subdir }; + } + } catch { /* session not found, skip */ } + } const options = { run, commandId, image, managerUrl: managerUrl(args), namespace: optionalFlag(args, "namespace") ?? "agentrun-v01", + ...(sessionPvc ? { sessionPvc } : {}), }; const attemptId = optionalFlag(args, "attempt-id"); const runnerId = optionalFlag(args, "runner-id");