From 96655f68aca897cd50ecb047ea7d705f09e3f1ed Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 6 Jul 2026 04:04:07 +0000 Subject: [PATCH] fix: resolve pac node pipelineruns by source label --- scripts/src/hwlab-node/render.ts | 45 ++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/scripts/src/hwlab-node/render.ts b/scripts/src/hwlab-node/render.ts index a674493d..12c05aa9 100644 --- a/scripts/src/hwlab-node/render.ts +++ b/scripts/src/hwlab-node/render.ts @@ -179,7 +179,8 @@ export function nodeRuntimeControlPlaneStatus(scoped: ReturnType | null }; + if (pipelineRunOverride === undefined && sourceCommit !== null && expectedPipelineRun !== null && pipelineRunProbe !== null && pipelineRunProbe.exists !== true) { + const resolved = resolveNodeRuntimePipelineRunBySourceCommit(spec, sourceCommit); + pipelineRunResolution.result = compactRuntimeCommand(resolved.result); + if (resolved.name !== null) { + pipelineRun = resolved.name; + pipelineRunResolution.resolvedName = resolved.name; + pipelineRunResolution.fallbackUsed = true; + pipelineRunProbe = getNodeRuntimePipelineRun(spec, resolved.name); + } + } const pipelineRunDiagnostics = pipelineRun !== null && pipelineRunProbe?.exists === true && pipelineRunProbe?.status !== "True" ? nodeRuntimePipelineRunDiagnostics(spec, pipelineRun) : null; @@ -288,6 +304,8 @@ export function nodeRuntimeControlPlaneStatus(scoped: ReturnType/dev/null \\", + " | awk -v prefix=\"$prefix\" 'index($2, prefix) == 1 { print $0 }' \\", + " | sort \\", + " | tail -n 1 \\", + " | awk '{print $2}'", + "}", + "name=$(find_by_selector \"hwlab.pikastech.local/source-commit=$source_commit\")", + "if [ -z \"$name\" ]; then name=$(find_by_selector \"unidesk.ai/source-commit=$source_commit\"); fi", + "if [ -z \"$name\" ]; then name=$(find_by_selector \"agentrun.pikastech.local/source-commit=$source_commit\"); fi", + "printf '%s\\n' \"$name\"", + ].join("\n"); + const result = runNodeK3sArgs(spec, ["sh", "--", script], 30); + const name = result.exitCode === 0 ? result.stdout.trim().split(/\r?\n/u).filter(Boolean).pop() ?? null : null; + return { name: name !== null && name.length > 0 ? name : null, result }; +} + export function nullableInteger(value: string): number | null { if (!/^[0-9]+$/u.test(value)) return null; return Number(value);