fix: 收敛 one-shot runner 成功终态
This commit is contained in:
@@ -158,6 +158,7 @@ function runnerEnv(options: RunnerJobRenderOptions, context: { namespace: string
|
||||
{ name: "AGENTRUN_K8S_JOB_NAME", value: context.jobName },
|
||||
{ name: "AGENTRUN_LOG_PATH", value: "/tmp/agentrun-runner.jsonl" },
|
||||
{ name: "AGENTRUN_RUNNER_IDLE_TIMEOUT_MS", value: "600000" },
|
||||
{ name: "AGENTRUN_RUNNER_ONE_SHOT", value: "true" },
|
||||
{ name: "HOME", value: "/home/agentrun" },
|
||||
{ name: "CODEX_HOME", value: codexHome },
|
||||
...(selectedSecret ? [{ name: "AGENTRUN_CODEX_SECRET_HOME", value: selectedSecret.projectionMountPath }] : []),
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function runOnce(options: RunnerOnceOptions): Promise<JsonRecord> {
|
||||
: await executeCommand(api, options, command, runner, attemptId, workspacePath);
|
||||
commandResults.push(result);
|
||||
if (options.oneShot === true) {
|
||||
const run = await api.getRun(options.runId);
|
||||
const run = await api.reportStatus(options.runId, { terminalStatus: result.terminalStatus, failureKind: result.failureKind, failureMessage: null });
|
||||
return { runner, commandId: command.id, terminalStatus: result.terminalStatus, failureKind: result.failureKind, run, commandsProcessed: commandResults.length, commandResults, stopped: "one-shot" } as JsonRecord;
|
||||
}
|
||||
}
|
||||
@@ -204,6 +204,7 @@ async function reportCommandFailure(api: RunnerManagerApi, runId: string, comman
|
||||
|
||||
async function reportCancelled(api: RunnerManagerApi, runId: string, commandId: string, runner: RunnerRecord, attemptId: string, message: string): Promise<CommandExecutionResult> {
|
||||
await api.reportCommandStatus(commandId, { terminalStatus: "cancelled", failureKind: "cancelled", failureMessage: message });
|
||||
await api.reportStatus(runId, { terminalStatus: "cancelled", failureKind: "cancelled", failureMessage: message });
|
||||
await api.appendEvent(runId, { type: "backend_status", payload: { phase: "turn-cancelled", commandId, attemptId, runnerId: runner.id, failureKind: "cancelled", message } });
|
||||
await api.appendEvent(runId, { type: "terminal_status", payload: { terminalStatus: "cancelled", failureKind: "cancelled", message, commandId, attemptId, runnerId: runner.id } });
|
||||
return { commandId, terminalStatus: "cancelled", failureKind: "cancelled" };
|
||||
|
||||
@@ -126,6 +126,7 @@ function assertRunnerJobUsesWritableCodexHome(manifest: JsonRecord, expectedCode
|
||||
assert.equal(value("HOME"), "/home/agentrun");
|
||||
assert.equal(value("CODEX_HOME"), expectedCodexHome);
|
||||
assert.equal(value("AGENTRUN_CODEX_SECRET_HOME"), projectionPath);
|
||||
assert.equal(value("AGENTRUN_RUNNER_ONE_SHOT"), "true");
|
||||
assert.notEqual(value("CODEX_HOME"), value("AGENTRUN_CODEX_SECRET_HOME"));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ const selfTest: SelfTestCase = async (context) => {
|
||||
assert.ok(events.items?.some((event) => event.type === "backend_status" && JSON.stringify(event.payload).includes("run-claimed")));
|
||||
assertNoSecretLeak(events);
|
||||
const finalRun = await client.get(`/api/v1/runs/${happy.runId}`) as { terminalStatus?: string | null; status?: string };
|
||||
assert.equal(finalRun.terminalStatus, null);
|
||||
assert.equal(finalRun.status, "claimed");
|
||||
assert.equal(finalRun.terminalStatus, "completed");
|
||||
assert.equal(finalRun.status, "completed");
|
||||
const finalCommand = await client.get(`/api/v1/runs/${happy.runId}/commands/${happy.commandId}`) as { state?: string };
|
||||
assert.equal(finalCommand.state, "completed");
|
||||
|
||||
|
||||
@@ -140,6 +140,10 @@ async function assertResourceBundleFailure(client: ManagerClient, context: SelfT
|
||||
assert.equal(envelope.failureKind, "infra-failed");
|
||||
const commandRecord = await client.get(`/api/v1/runs/${run.id}/commands/${command.id}`) as { state?: string };
|
||||
assert.equal(commandRecord.state, "failed");
|
||||
const runRecord = await client.get(`/api/v1/runs/${run.id}`) as { status?: string; terminalStatus?: string; failureKind?: string };
|
||||
assert.equal(runRecord.status, "failed");
|
||||
assert.equal(runRecord.terminalStatus, "failed");
|
||||
assert.equal(runRecord.failureKind, "infra-failed");
|
||||
}
|
||||
|
||||
function runPayload(context: SelfTestContext, backendProfile: BackendProfile, sessionId: string): JsonRecord {
|
||||
|
||||
Reference in New Issue
Block a user