fix: support v03 control-plane retry visibility

This commit is contained in:
Codex
2026-06-08 15:48:41 +00:00
parent 8f51bbca91
commit 47dd562697
4 changed files with 161 additions and 14 deletions
+82 -11
View File
@@ -361,12 +361,12 @@ function parseControlPlaneOptions(args: string[]): G14ControlPlaneOptions {
actionRaw !== "cleanup-released-pvs" &&
actionRaw !== "runtime-migration"
) {
throw new Error("control-plane usage: status|apply|trigger-current|refresh --lane v02|v03 | closeout|runtime-migration --lane v02 | cleanup-runs --lane v02|g14|all | cleanup-released-pvs --lane all [--dry-run|--confirm]");
throw new Error("control-plane usage: status|apply|trigger-current|refresh --lane v02|v03 | closeout|runtime-migration --lane v02 | cleanup-runs --lane v02|v03|g14|all | cleanup-released-pvs --lane all [--dry-run|--confirm]");
}
const laneRaw = optionValue(args, "--lane") ?? (actionRaw === "cleanup-released-pvs" ? "all" : "v02");
let lane: G14ControlPlaneOptions["lane"];
if (actionRaw === "cleanup-runs") {
if (laneRaw !== "v02" && laneRaw !== "g14" && laneRaw !== "all") throw new Error("control-plane cleanup-runs requires --lane v02|g14|all");
if (laneRaw !== "g14" && laneRaw !== "all" && !isHwlabRuntimeLane(laneRaw)) throw new Error("control-plane cleanup-runs requires --lane v02|v03|g14|all");
lane = laneRaw;
} else if (actionRaw === "cleanup-released-pvs") {
if (laneRaw !== "all") throw new Error("control-plane cleanup-released-pvs requires --lane all because released PVs no longer preserve the v02/g14 PipelineRun lane");
@@ -918,6 +918,14 @@ function printV02PrMonitorProgress(data: Record<string, unknown> = {}): void {
printProgressEvent("hwlab.v02.pr-monitor.progress", data);
}
function printRuntimeLaneTriggerProgress(spec: HwlabRuntimeLaneSpec, data: Record<string, unknown> = {}): void {
printProgressEvent("hwlab.runtime-lane.trigger.progress", {
lane: spec.lane,
node: spec.nodeId,
...data,
});
}
function shortSha(sha: string): string {
return sha.slice(0, 12);
}
@@ -2560,10 +2568,10 @@ function listV02PipelineRunsCompactFromText(text: string, commandOk: boolean, co
return parsePipelineRunRows(text, limit, nowMs);
}
function pipelinePrefixesForLane(lane: "v02" | "g14" | "all"): string[] {
if (lane === "v02") return ["hwlab-v02-ci-poll-"];
function pipelinePrefixesForLane(lane: G14ControlPlaneOptions["lane"]): string[] {
if (isHwlabRuntimeLane(lane)) return [`${hwlabRuntimeLaneSpec(lane).pipelineRunPrefix}-`];
if (lane === "g14") return ["hwlab-g14-ci-poll-"];
return ["hwlab-v02-ci-poll-", "hwlab-g14-ci-poll-"];
return [...hwlabRuntimeLaneIds().map((runtimeLane) => `${hwlabRuntimeLaneSpec(runtimeLane).pipelineRunPrefix}-`), "hwlab-g14-ci-poll-"];
}
function commandErrorSummary(result: CommandJsonResult): string {
@@ -2579,8 +2587,8 @@ function tailText(value: unknown, maxBytes = 2000): string {
}
function listCleanupPipelineRuns(options: G14ControlPlaneOptions): Record<string, unknown>[] {
if (options.lane !== "v02" && options.lane !== "g14" && options.lane !== "all") {
throw new Error("control-plane cleanup-runs requires --lane v02|g14|all");
if (options.lane !== "g14" && options.lane !== "all" && !isHwlabRuntimeLane(options.lane)) {
throw new Error("control-plane cleanup-runs requires --lane v02|v03|g14|all");
}
const result = g14K3s([
"kubectl",
@@ -2594,7 +2602,11 @@ function listCleanupPipelineRuns(options: G14ControlPlaneOptions): Record<string
if (!isCommandSuccess(result)) {
throw new Error(`failed to list hwlab-ci PipelineRuns: ${commandErrorSummary(result)}`);
}
const targetPipelineRun = options.pipelineRun ?? (options.sourceCommit === undefined ? undefined : v02PipelineRunName(options.sourceCommit));
const targetPipelineRun = options.pipelineRun ?? (options.sourceCommit === undefined
? undefined
: isHwlabRuntimeLane(options.lane)
? runtimeLanePipelineRunName(hwlabRuntimeLaneSpec(options.lane), options.sourceCommit)
: v02PipelineRunName(options.sourceCommit));
const prefixes = pipelinePrefixesForLane(options.lane);
const now = Date.now();
const terminalRuns = statusText(result)
@@ -2831,6 +2843,7 @@ function runControlPlaneCleanup(options: G14ControlPlaneOptions): Record<string,
.filter((item) => item.selected !== false)
.map((item) => String(item.name));
const ownedPvcs = listOwnedWorkspacePvcs(candidateNames);
const followUpStatusLane = isHwlabRuntimeLane(options.lane) ? options.lane : "v02";
if (options.dryRun) {
return {
ok: true,
@@ -2875,7 +2888,7 @@ function runControlPlaneCleanup(options: G14ControlPlaneOptions): Record<string,
ownedPvcCountBefore: ownedPvcs.length,
deletion,
followUp: {
status: "bun scripts/cli.ts hwlab g14 control-plane status --lane v02",
status: `bun scripts/cli.ts hwlab g14 control-plane status --lane ${followUpStatusLane}`,
diskPressure: "trans G14:k3s kubectl get node ubuntu-rog-zephyrus-g14-ga401iv-ga401iv -o jsonpath='{.spec.taints}{\"\\n\"}{range .status.conditions[*]}{.type}{\"=\"}{.status}{\" \"}{.reason}{\"\\n\"}{end}'",
},
};
@@ -3859,13 +3872,14 @@ function refreshRuntimeLaneArgoApplication(spec: HwlabRuntimeLaneSpec, options:
}
function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14ControlPlaneOptions): Record<string, unknown> {
if (options.action === "closeout" || options.action === "runtime-migration" || options.action === "cleanup-runs" || options.action === "cleanup-released-pvs") {
if (options.action === "cleanup-runs") return runControlPlaneCleanup(options);
if (options.action === "closeout" || options.action === "runtime-migration" || options.action === "cleanup-released-pvs") {
return {
ok: false,
command: `hwlab g14 control-plane ${options.action} --lane ${spec.lane}`,
lane: spec.lane,
degradedReason: "unsupported-runtime-lane-action",
message: `${options.action} is still v0.2-specific; v0.3+ currently supports status/apply/trigger-current/refresh`,
message: `${options.action} is still v0.2-specific; v0.3+ currently supports status/apply/trigger-current/refresh/cleanup-runs`,
};
}
if (options.action === "status" && options.pipelineRun !== undefined) {
@@ -4000,6 +4014,12 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont
next: { status: `bun scripts/cli.ts hwlab g14 control-plane status --lane ${spec.lane} --pipeline-run ${pipelineRun}` },
};
}
printRuntimeLaneTriggerProgress(spec, {
stage: "git-mirror-sync",
status: "started",
sourceCommit,
pipelineRun,
});
const gitMirrorSync = runGitMirrorSync({
action: "sync",
lane: spec.lane,
@@ -4008,6 +4028,14 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont
wait: true,
timeoutSeconds: options.timeoutSeconds,
});
printRuntimeLaneTriggerProgress(spec, {
stage: "git-mirror-sync",
status: gitMirrorSync.ok === true ? "succeeded" : "failed",
sourceCommit,
pipelineRun,
jobName: gitMirrorSync.jobName ?? null,
elapsedMs: gitMirrorSync.elapsedMs ?? null,
});
if (gitMirrorSync.ok !== true) {
return {
ok: false,
@@ -4021,7 +4049,21 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont
degradedReason: "git-mirror-sync-before-trigger-failed",
};
}
printRuntimeLaneTriggerProgress(spec, {
stage: "source-render",
status: "started",
sourceCommit,
pipelineRun,
});
const render = runRuntimeLaneRenderToTemp(spec, sourceCommit);
printRuntimeLaneTriggerProgress(spec, {
stage: "source-render",
status: isCommandSuccess(render.result) ? "succeeded" : "failed",
sourceCommit,
pipelineRun,
renderDir: render.renderDir,
exitCode: render.result.exitCode,
});
if (!isCommandSuccess(render.result)) {
return {
ok: false,
@@ -4038,8 +4080,22 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont
degradedReason: "control-plane-render-failed",
};
}
printRuntimeLaneTriggerProgress(spec, {
stage: "control-plane-apply",
status: "started",
sourceCommit,
pipelineRun,
renderDir: render.renderDir,
});
const apply = applyRuntimeLaneControlPlaneFiles(spec, render.renderDir, false, options.timeoutSeconds);
const cleanupRenderDir = isCommandSuccess(apply) ? cleanupRuntimeLaneRenderDir(spec, render.renderDir) : null;
printRuntimeLaneTriggerProgress(spec, {
stage: "control-plane-apply",
status: isCommandSuccess(apply) ? "succeeded" : "failed",
sourceCommit,
pipelineRun,
exitCode: apply.exitCode,
});
if (!isCommandSuccess(apply)) {
return {
ok: false,
@@ -4058,7 +4114,20 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont
degradedReason: "control-plane-apply-before-trigger-failed",
};
}
printRuntimeLaneTriggerProgress(spec, {
stage: "create-pipelinerun",
status: "started",
sourceCommit,
pipelineRun,
});
const create = createRuntimeLanePipelineRun(spec, sourceCommit, options.timeoutSeconds);
printRuntimeLaneTriggerProgress(spec, {
stage: "create-pipelinerun",
status: isCommandSuccess(create) ? "succeeded" : "failed",
sourceCommit,
pipelineRun,
exitCode: create.exitCode,
});
return {
ok: isCommandSuccess(create),
command: `hwlab g14 control-plane trigger-current --lane ${spec.lane}`,
@@ -8682,6 +8751,8 @@ export function hwlabG14Help(): Record<string, unknown> {
"bun scripts/cli.ts hwlab g14 control-plane cleanup-runs --lane v02 --min-age-minutes 30 --limit 20 --confirm",
"bun scripts/cli.ts hwlab g14 control-plane cleanup-runs --lane v02 --pipeline-run hwlab-v02-ci-poll-<short-sha> --dry-run",
"bun scripts/cli.ts hwlab g14 control-plane cleanup-runs --lane v02 --source-commit <full-sha> --confirm",
"bun scripts/cli.ts hwlab nodes control-plane cleanup-runs --node G14 --lane v03 --pipeline-run hwlab-v03-ci-poll-<short-sha> --dry-run",
"bun scripts/cli.ts hwlab nodes control-plane cleanup-runs --node G14 --lane v03 --source-commit <full-sha> --confirm",
"bun scripts/cli.ts hwlab g14 control-plane cleanup-released-pvs --lane all --limit 20 --dry-run",
"bun scripts/cli.ts hwlab g14 control-plane cleanup-released-pvs --lane all --limit 20 --confirm",
"bun scripts/cli.ts hwlab g14 control-plane runtime-migration --lane v02 --dry-run",