fix: stabilize AgentRun v01 control-plane CLI

This commit is contained in:
Codex
2026-06-01 16:27:14 +00:00
parent f00b946472
commit 79933f3c58
+18 -3
View File
@@ -69,7 +69,9 @@ async function status(config: UniDeskConfig): Promise<Record<string, unknown>> {
`git ls-remote origin ${gitopsBranch} 2>/dev/null | awk '{print $1}' || true`,
"git status --short --branch",
].join("\n")]);
const sourceCommit = matchLine(source.stdout, "sourceCommit=");
const localSourceCommit = matchLine(source.stdout, "sourceCommit=");
const originSourceCommit = matchLine(source.stdout, "originV01=");
const sourceCommit = isGitSha(originSourceCommit ?? "") ? originSourceCommit : localSourceCommit;
const gitopsLatest = matchLine(source.stdout, "gitopsLatest=");
const pipelineRun = sourceCommit ? pipelineRunName(sourceCommit) : null;
const k3s = await capture(config, g14K3sRoute, ["script", "--", statusScript(pipelineRun)]);
@@ -79,11 +81,15 @@ async function status(config: UniDeskConfig): Promise<Record<string, unknown>> {
command: "agentrun v01 control-plane status",
lane: "v0.1",
sourceCommit,
sourceCommitSource: sourceCommit === originSourceCommit ? "origin/v0.1" : "local-head",
localSourceCommit,
originSourceCommit,
gitopsLatest,
expectedPipelineRun: pipelineRun,
source: compactCapture(source),
runtime: compactCapture(k3s),
runtimeAlignment: {
localHeadMatchesOrigin: Boolean(localSourceCommit && originSourceCommit && localSourceCommit === originSourceCommit),
argoRevision: argo.revision,
argoSyncStatus: argo.syncStatus,
argoHealthStatus: argo.healthStatus,
@@ -101,9 +107,12 @@ async function triggerCurrent(config: UniDeskConfig, options: TriggerOptions): P
"set -eu",
"cd /root/agentrun-v01",
"git fetch origin v0.1",
"git pull --ff-only origin v0.1",
"git merge --ff-only refs/remotes/origin/v0.1",
"printf 'sourceCommit='",
"git rev-parse HEAD",
"printf 'originV01='",
"git rev-parse refs/remotes/origin/v0.1",
"git status --short --branch",
].join("\n")]);
const sourceCommit = matchLine(source.stdout, "sourceCommit=");
const pipelineRun = sourceCommit ? pipelineRunName(sourceCommit) : null;
@@ -198,7 +207,13 @@ function statusScript(pipelineRun: string | null): string {
"printf 'argo\\n'",
`kubectl -n ${argoNamespace} get application ${argoApplication} -o 'jsonpath={.status.sync.revision}{"\\t"}{.status.sync.status}{"\\t"}{.status.health.status}{"\\n"}' 2>/dev/null || true`,
"printf 'workloads\\n'",
`kubectl -n ${runtimeNamespace} get deploy,sts,pod -o wide 2>/dev/null || true`,
`kubectl -n ${runtimeNamespace} get deploy,sts -o wide 2>/dev/null || true`,
"printf 'managerImage\\n'",
`kubectl -n ${runtimeNamespace} get deploy agentrun-mgr -o 'jsonpath={.spec.template.spec.containers[0].image}{"\\t"}{.spec.template.spec.containers[0].env[?(@.name=="AGENTRUN_SOURCE_COMMIT")].value}{"\\n"}' 2>/dev/null || true`,
"printf 'managerPods\\n'",
`kubectl -n ${runtimeNamespace} get pod -l app.kubernetes.io/name=agentrun-mgr -o 'custom-columns=NAME:.metadata.name,READY:.status.containerStatuses[*].ready,STATUS:.status.phase,RESTARTS:.status.containerStatuses[*].restartCount,CREATED:.metadata.creationTimestamp' --no-headers 2>/dev/null || true`,
"printf 'recentRunnerPods\\n'",
`kubectl -n ${runtimeNamespace} get pod -l app.kubernetes.io/component=runner --sort-by=.metadata.creationTimestamp -o 'custom-columns=NAME:.metadata.name,READY:.status.containerStatuses[*].ready,STATUS:.status.phase,RESTARTS:.status.containerStatuses[*].restartCount,CREATED:.metadata.creationTimestamp' --no-headers 2>/dev/null | tail -n 8 || true`,
].join("\n");
}