Merge pull request #1038 from pikasTech/fix/1032-k3s-build-benchmark-start-visibility
fix: render k3s build benchmark jobs as json
This commit is contained in:
@@ -181,7 +181,7 @@ function startBenchmarks(plans: readonly TargetPlan[], options: K3sBuildBenchmar
|
||||
row.state,
|
||||
row.jobName,
|
||||
row.runId,
|
||||
row.ok ? `status/logs/traffic` : `${row.blocker}: ${row.detail}`,
|
||||
startRowDetail(row),
|
||||
]);
|
||||
return {
|
||||
ok,
|
||||
@@ -202,6 +202,17 @@ function startBenchmarks(plans: readonly TargetPlan[], options: K3sBuildBenchmar
|
||||
};
|
||||
}
|
||||
|
||||
function startRowDetail(row: TargetPlan & { started: boolean; state: string; jobName: string; runId: string; result: unknown }): string {
|
||||
if (!row.ok) return `${row.blocker}: ${row.detail}`;
|
||||
if (row.started) return "status/logs/traffic";
|
||||
const result = record(row.result);
|
||||
const stderr = text(result.stderrPreview, "");
|
||||
const stdout = text(result.stdoutPreview, "");
|
||||
const exitCode = text(result.exitCode, "-");
|
||||
const detail = stderr || stdout || "start-failed";
|
||||
return `exit=${exitCode} ${detail.replace(/\s+/gu, " ").slice(0, 180)}`;
|
||||
}
|
||||
|
||||
function statusBenchmarks(plans: readonly TargetPlan[], options: K3sBuildBenchmarkOptions): RenderedCliResult {
|
||||
const statuses = plans.map((plan): TargetStatus => {
|
||||
if (!plan.ok || plan.target === undefined || plan.profile === undefined) {
|
||||
@@ -410,7 +421,7 @@ function benchmarkLabels(target: Sub2ApiTargetConfig, profile: K3sBuildBenchmark
|
||||
}
|
||||
|
||||
function startScript(manifest: Record<string, unknown>, target: Sub2ApiTargetConfig, profile: K3sBuildBenchmarkProfile, runId: string, jobName: string): string {
|
||||
const yaml = `${Bun.YAML.stringify(manifest).trim()}\n`;
|
||||
const yaml = `${JSON.stringify(manifest, null, 2)}\n`;
|
||||
const encoded = Buffer.from(yaml, "utf8").toString("base64");
|
||||
return `
|
||||
set -eu
|
||||
@@ -481,7 +492,7 @@ elif active:
|
||||
state = "running"
|
||||
else:
|
||||
state = "pending"
|
||||
failure_family = "none" if state == "succeeded" else "unknown"
|
||||
failure_family = "none" if state == "succeeded" else ("in-progress" if state in ("running", "pending") else "unknown")
|
||||
tail_text = (full_logs or logs)[-4000:]
|
||||
if state == "missing":
|
||||
failure_family = "job-missing"
|
||||
@@ -553,11 +564,13 @@ function trafficSpec(target: Sub2ApiTargetConfig): EgressProxyTrafficSpec {
|
||||
function normalizeStatus(plan: TargetPlan, parsed: unknown, result: CommandResult): TargetStatus {
|
||||
const data = typeof parsed === "object" && parsed !== null ? parsed as Record<string, unknown> : {};
|
||||
const jobResult = record(data.result);
|
||||
const state = text(data.state, result.exitCode === 0 ? "unknown" : "failed");
|
||||
const commandOk = result.exitCode === 0 && state !== "failed" && state !== "missing" && text(data.reason, "") !== "kubectl-jobs-failed";
|
||||
const status: TargetStatus = {
|
||||
ok: result.exitCode === 0 && data.ok === true,
|
||||
ok: commandOk,
|
||||
targetId: plan.targetId,
|
||||
profile: text(data.profile, plan.profile?.id ?? "-"),
|
||||
state: text(data.state, result.exitCode === 0 ? "unknown" : "failed"),
|
||||
state,
|
||||
jobName: text(data.jobName),
|
||||
runId: text(data.runId),
|
||||
startedAt: text(data.startedAt),
|
||||
@@ -566,7 +579,7 @@ function normalizeStatus(plan: TargetPlan, parsed: unknown, result: CommandResul
|
||||
outputMiB: nullableNumber(jobResult.outputMiB),
|
||||
downloadMiB: nullableNumber(jobResult.downloadMiB),
|
||||
payloadMiB: nullableNumber(jobResult.payloadMiB),
|
||||
failureFamily: text(data.failureFamily, data.ok === true ? "none" : text(data.reason, "unknown")),
|
||||
failureFamily: text(data.failureFamily, data.ok === true ? "none" : state === "running" || state === "pending" ? "in-progress" : text(data.reason, "unknown")),
|
||||
logTail: text(data.logTail, result.stderr.slice(-2000)),
|
||||
};
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user