fix(v0.1): recover session PVC when prior create left session without storage
之前的失败用例会让 session 留在 storageKind=none 状态但 pvcName 缺失, 现在 POST /api/v1/sessions 在 storageKind=none || !storagePvcName 时 重新调 createSessionPvc 补建,action=session-storage-recovered。 selftest 覆盖:显式 reset storageKind=none 后第二次 POST 走 recovery。
This commit is contained in:
@@ -179,6 +179,10 @@ async function route({ method, url, body, store, sourceCommit, runnerJobDefaults
|
||||
const existing = await store.getSession(sessionId);
|
||||
if (existing) {
|
||||
if (existing.storageKind === "evicted") throw new AgentRunError("session-store-evicted", `session ${sessionId} storage has been evicted; create a new sessionId`, { httpStatus: 409 });
|
||||
if (existing.storageKind === "none" || !existing.storagePvcName) {
|
||||
const recovered = await createSessionPvc({ store, sessionId, options: { ...sessionPvcOptionsForRequest(sessionPvcDefaults, runnerJobDefaults), defaultCodexRolloutSubdir: codexRolloutSubdir } });
|
||||
return { action: "session-storage-recovered", session: existing, pvc: recovered, valuesPrinted: false } as unknown as JsonValue;
|
||||
}
|
||||
return { action: "session-exists", session: existing, pvcName: existing.storagePvcName ?? null, pvcPhase: existing.storagePvcPhase ?? null, codexRolloutSubdir: existing.codexRolloutSubdir ?? "sessions", valuesPrinted: false } as unknown as JsonValue;
|
||||
}
|
||||
const now = new Date().toISOString();
|
||||
|
||||
Reference in New Issue
Block a user