fix: bound branch follower debug json
This commit is contained in:
+34
-10
@@ -140,28 +140,31 @@ function runTargetDebugStepJob(registry: BranchFollowerRegistry, options: Parsed
|
||||
const parsed = parseLastJsonObject(result.stdout);
|
||||
const state = deps.readK8sState(registry, options);
|
||||
const followerId = options.followerId ?? "";
|
||||
const compact = compactTargetDebugResult(parsed);
|
||||
const ok = result.exitCode === 0 && parsed?.ok !== false;
|
||||
const includeTargetTail = !ok || parsed === null;
|
||||
const fallbackStateAfter = stateSnapshot(state, followerId);
|
||||
return {
|
||||
ok: result.exitCode === 0 && parsed?.ok !== false,
|
||||
ok,
|
||||
action: "debug-step",
|
||||
step,
|
||||
follower: followerId,
|
||||
execution: "k8s-native-debug-job",
|
||||
dryRun: !options.confirm,
|
||||
stateBefore: asOptionalRecord(parsed?.stateBefore),
|
||||
status: asOptionalRecord(parsed?.status),
|
||||
decision: asOptionalRecord(parsed?.decision),
|
||||
stateWrite: asOptionalRecord(parsed?.stateWrite),
|
||||
stateBefore: compact?.stateBefore ?? compactStateLike(asOptionalRecord(parsed?.stateBefore)),
|
||||
status: compact?.status ?? null,
|
||||
decision: compact?.decision ?? null,
|
||||
stateWrite: compact?.stateWrite ?? null,
|
||||
target: {
|
||||
name: jobName,
|
||||
namespace: registry.controller.namespace,
|
||||
exitCode: result.exitCode,
|
||||
timedOut: result.timedOut,
|
||||
parsed: parsed !== null,
|
||||
stdoutTail: redactText(tailText(result.stdout, 1000)),
|
||||
stderrTail: redactText(tailText(result.stderr, 800)),
|
||||
stdoutTail: includeTargetTail ? redactText(tailText(result.stdout, 1000)) : "",
|
||||
stderrTail: includeTargetTail ? redactText(tailText(result.stderr, 800)) : "",
|
||||
},
|
||||
targetResult: compactTargetDebugResult(parsed),
|
||||
stateAfter: asOptionalRecord(parsed?.stateAfter) ?? stateSnapshot(state, followerId),
|
||||
stateAfter: compact?.stateAfter ?? compactStateLike(asOptionalRecord(parsed?.stateAfter) ?? fallbackStateAfter),
|
||||
parsedDownstreamCliOutput: false,
|
||||
next: debugNext(followerId),
|
||||
};
|
||||
@@ -335,7 +338,28 @@ function compactFollowerDecision(state: FollowerState): Record<string, unknown>
|
||||
pipelineRun: state.pipelineRun,
|
||||
inFlightJob: state.inFlightJob,
|
||||
decision: state.decision,
|
||||
timings: state.timings,
|
||||
timings: compactDebugTimings(state.timings),
|
||||
};
|
||||
}
|
||||
|
||||
function compactDebugTimings(timings: FollowerState["timings"]): Record<string, unknown> {
|
||||
return {
|
||||
budgetSeconds: timings.budgetSeconds,
|
||||
totalSeconds: timings.totalSeconds,
|
||||
totalStatus: timings.totalStatus,
|
||||
totalSource: timings.totalSource,
|
||||
sourceCommit: timings.sourceCommit,
|
||||
startedAt: timings.startedAt,
|
||||
finishedAt: timings.finishedAt,
|
||||
overBudget: timings.overBudget,
|
||||
stages: timings.stages.slice(0, 8).map((stage) => ({
|
||||
stage: stage.stage,
|
||||
status: stage.status,
|
||||
seconds: stage.seconds,
|
||||
budgetSeconds: stage.budgetSeconds,
|
||||
source: stage.source,
|
||||
object: stage.object,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user