feat(v0.1): CLI runner job --dry-run 也查 session 加 sessionPvc
之前 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 一致。
This commit is contained in:
@@ -8,6 +8,7 @@ import { MemoryAgentRunStore } from "../../src/mgr/store.js";
|
|||||||
import { ManagerClient } from "../../src/mgr/client.js";
|
import { ManagerClient } from "../../src/mgr/client.js";
|
||||||
import { runOnce } from "../../src/runner/run-once.js";
|
import { runOnce } from "../../src/runner/run-once.js";
|
||||||
import { renderRunnerJobDryRun } from "../../src/runner/k8s-job.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 { renderCodexProviderSecretPlan } from "./secret-render.js";
|
||||||
import type { BackendProfile, CommandRecord, JsonRecord, JsonValue, RunRecord, SessionSummary } from "../../src/common/types.js";
|
import type { BackendProfile, CommandRecord, JsonRecord, JsonValue, RunRecord, SessionSummary } from "../../src/common/types.js";
|
||||||
import { AgentRunError, errorToJson } from "../../src/common/errors.js";
|
import { AgentRunError, errorToJson } from "../../src/common/errors.js";
|
||||||
@@ -341,12 +342,23 @@ async function renderRunnerJob(args: ParsedArgs): Promise<JsonRecord> {
|
|||||||
}
|
}
|
||||||
if (!image) throw new AgentRunError("schema-invalid", "runner job --dry-run requires --image", { httpStatus: 2 });
|
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;
|
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 = {
|
const options = {
|
||||||
run,
|
run,
|
||||||
commandId,
|
commandId,
|
||||||
image,
|
image,
|
||||||
managerUrl: managerUrl(args),
|
managerUrl: managerUrl(args),
|
||||||
namespace: optionalFlag(args, "namespace") ?? "agentrun-v01",
|
namespace: optionalFlag(args, "namespace") ?? "agentrun-v01",
|
||||||
|
...(sessionPvc ? { sessionPvc } : {}),
|
||||||
};
|
};
|
||||||
const attemptId = optionalFlag(args, "attempt-id");
|
const attemptId = optionalFlag(args, "attempt-id");
|
||||||
const runnerId = optionalFlag(args, "runner-id");
|
const runnerId = optionalFlag(args, "runner-id");
|
||||||
|
|||||||
Reference in New Issue
Block a user