fix(agentrun): accept yaml lane pipelinerun status
This commit is contained in:
@@ -372,7 +372,7 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio
|
|||||||
...(sourcePayload.workspaceClean === true || sourcePayload.workspaceExists !== true ? [] : ["source-worktree-dirty"]),
|
...(sourcePayload.workspaceClean === true || sourcePayload.workspaceExists !== true ? [] : ["source-worktree-dirty"]),
|
||||||
...(mirrorPayload.readReady === true ? [] : ["git-mirror-read-not-ready"]),
|
...(mirrorPayload.readReady === true ? [] : ["git-mirror-read-not-ready"]),
|
||||||
...(mirrorPayload.writeReady === true ? [] : ["git-mirror-write-not-ready"]),
|
...(mirrorPayload.writeReady === true ? [] : ["git-mirror-write-not-ready"]),
|
||||||
...(mirrorPayload.cachePvcExists === true ? [] : ["git-mirror-cache-pvc-missing"]),
|
...(mirrorPayload.cacheReady === true ? [] : ["git-mirror-cache-not-ready"]),
|
||||||
...(runtimePayload.ciNamespaceExists === true ? [] : ["ci-namespace-missing"]),
|
...(runtimePayload.ciNamespaceExists === true ? [] : ["ci-namespace-missing"]),
|
||||||
...(pipeline.exists === true ? [] : ["pipeline-missing"]),
|
...(pipeline.exists === true ? [] : ["pipeline-missing"]),
|
||||||
...(pipelineRunName !== null && pipelineRunStatus.exists !== true ? ["pipelinerun-missing"] : []),
|
...(pipelineRunName !== null && pipelineRunStatus.exists !== true ? ["pipelinerun-missing"] : []),
|
||||||
@@ -432,7 +432,10 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio
|
|||||||
const compactGitMirrorStatus = {
|
const compactGitMirrorStatus = {
|
||||||
readReady: mirrorPayload.readReady ?? false,
|
readReady: mirrorPayload.readReady ?? false,
|
||||||
writeReady: mirrorPayload.writeReady ?? false,
|
writeReady: mirrorPayload.writeReady ?? false,
|
||||||
|
cacheMode: mirrorPayload.cacheMode ?? null,
|
||||||
|
cacheReady: mirrorPayload.cacheReady ?? false,
|
||||||
cachePvcExists: mirrorPayload.cachePvcExists ?? false,
|
cachePvcExists: mirrorPayload.cachePvcExists ?? false,
|
||||||
|
cacheHostPath: mirrorPayload.cacheHostPath ?? null,
|
||||||
sourceCommit: mirrorSourceCommit,
|
sourceCommit: mirrorSourceCommit,
|
||||||
gitopsCommit: expectedGitopsRevision,
|
gitopsCommit: expectedGitopsRevision,
|
||||||
alreadySynced: mirrorAlreadySynced,
|
alreadySynced: mirrorAlreadySynced,
|
||||||
@@ -496,7 +499,10 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio
|
|||||||
gitMirror: {
|
gitMirror: {
|
||||||
readReady: mirrorPayload.readReady ?? false,
|
readReady: mirrorPayload.readReady ?? false,
|
||||||
writeReady: mirrorPayload.writeReady ?? false,
|
writeReady: mirrorPayload.writeReady ?? false,
|
||||||
|
cacheMode: mirrorPayload.cacheMode ?? null,
|
||||||
|
cacheReady: mirrorPayload.cacheReady ?? false,
|
||||||
cachePvcExists: mirrorPayload.cachePvcExists ?? false,
|
cachePvcExists: mirrorPayload.cachePvcExists ?? false,
|
||||||
|
cacheHostPath: mirrorPayload.cacheHostPath ?? null,
|
||||||
repositoryCount: Array.isArray(mirrorPayload.repositories) ? mirrorPayload.repositories.length : null,
|
repositoryCount: Array.isArray(mirrorPayload.repositories) ? mirrorPayload.repositories.length : null,
|
||||||
sourceCommit: mirrorSourceCommit,
|
sourceCommit: mirrorSourceCommit,
|
||||||
gitopsCommit: expectedGitopsRevision,
|
gitopsCommit: expectedGitopsRevision,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function agentRunHelp(): unknown {
|
|||||||
"bun scripts/cli.ts agentrun control-plane trigger-current --node D601 --lane v02 --confirm",
|
"bun scripts/cli.ts agentrun control-plane trigger-current --node D601 --lane v02 --confirm",
|
||||||
"bun scripts/cli.ts agentrun control-plane status",
|
"bun scripts/cli.ts agentrun control-plane status",
|
||||||
"bun scripts/cli.ts agentrun control-plane status --full",
|
"bun scripts/cli.ts agentrun control-plane status --full",
|
||||||
"bun scripts/cli.ts agentrun control-plane status --pipeline-run agentrun-vNN-ci-<short-sha>",
|
"bun scripts/cli.ts agentrun control-plane status --pipeline-run <yaml-lane-pipelinerun>",
|
||||||
"bun scripts/cli.ts agentrun control-plane status --source-commit <full-sha>",
|
"bun scripts/cli.ts agentrun control-plane status --source-commit <full-sha>",
|
||||||
"bun scripts/cli.ts agentrun control-plane expose --dry-run",
|
"bun scripts/cli.ts agentrun control-plane expose --dry-run",
|
||||||
"bun scripts/cli.ts agentrun control-plane expose --confirm",
|
"bun scripts/cli.ts agentrun control-plane expose --confirm",
|
||||||
@@ -279,7 +279,7 @@ export function agentRunHelpText(args: string[]): string {
|
|||||||
" bun scripts/cli.ts agentrun control-plane secret-sync --node D601 --lane v02 --dry-run",
|
" bun scripts/cli.ts agentrun control-plane secret-sync --node D601 --lane v02 --dry-run",
|
||||||
" bun scripts/cli.ts agentrun control-plane trigger-current --node D601 --lane v02 --dry-run",
|
" bun scripts/cli.ts agentrun control-plane trigger-current --node D601 --lane v02 --dry-run",
|
||||||
" bun scripts/cli.ts agentrun control-plane status",
|
" bun scripts/cli.ts agentrun control-plane status",
|
||||||
" bun scripts/cli.ts agentrun control-plane status --pipeline-run agentrun-vNN-ci-<short-sha>",
|
" bun scripts/cli.ts agentrun control-plane status --pipeline-run <yaml-lane-pipelinerun>",
|
||||||
" bun scripts/cli.ts agentrun control-plane expose --dry-run",
|
" bun scripts/cli.ts agentrun control-plane expose --dry-run",
|
||||||
" bun scripts/cli.ts agentrun control-plane trigger-current --dry-run",
|
" bun scripts/cli.ts agentrun control-plane trigger-current --dry-run",
|
||||||
" bun scripts/cli.ts agentrun control-plane cleanup-runners --node D601 --lane v02 --dry-run",
|
" bun scripts/cli.ts agentrun control-plane cleanup-runners --node D601 --lane v02 --dry-run",
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ export function parseStatusOptions(args: string[]): StatusOptions {
|
|||||||
if (arg === "--pipeline-run") {
|
if (arg === "--pipeline-run") {
|
||||||
const value = args[index + 1];
|
const value = args[index + 1];
|
||||||
if (value === undefined || value.startsWith("--")) throw new Error("--pipeline-run requires a value");
|
if (value === undefined || value.startsWith("--")) throw new Error("--pipeline-run requires a value");
|
||||||
if (!isAgentRunPipelineRunName(value)) throw new Error("--pipeline-run must be an agentrun-vNN-ci-<12+ hex> PipelineRun name");
|
if (!isAgentRunPipelineRunName(value)) throw new Error("--pipeline-run must be a YAML lane AgentRun PipelineRun name ending in ci-<12+ hex>");
|
||||||
pipelineRun = value;
|
pipelineRun = value;
|
||||||
index += 1;
|
index += 1;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -602,6 +602,7 @@ export function yamlLaneGitMirrorStatusScript(spec: AgentRunLaneSpec): string {
|
|||||||
`read_service=${shQuote(spec.gitMirror.readService)}`,
|
`read_service=${shQuote(spec.gitMirror.readService)}`,
|
||||||
`write_service=${shQuote(spec.gitMirror.writeService)}`,
|
`write_service=${shQuote(spec.gitMirror.writeService)}`,
|
||||||
`cache_pvc=${shQuote(spec.gitMirror.cachePvc)}`,
|
`cache_pvc=${shQuote(spec.gitMirror.cachePvc)}`,
|
||||||
|
`cache_host_path=${spec.gitMirror.cacheHostPath === null ? "''" : shQuote(spec.gitMirror.cacheHostPath)}`,
|
||||||
`repository=${shQuote(spec.source.repository)}`,
|
`repository=${shQuote(spec.source.repository)}`,
|
||||||
`source_branch=${shQuote(spec.source.branch)}`,
|
`source_branch=${shQuote(spec.source.branch)}`,
|
||||||
`gitops_branch=${shQuote(spec.gitops.branch)}`,
|
`gitops_branch=${shQuote(spec.gitops.branch)}`,
|
||||||
@@ -612,13 +613,15 @@ export function yamlLaneGitMirrorStatusScript(spec: AgentRunLaneSpec): string {
|
|||||||
"write_exit=$?",
|
"write_exit=$?",
|
||||||
"kubectl -n \"$namespace\" get pvc \"$cache_pvc\" -o json >/tmp/agentrun-gitmirror-cache.json 2>/dev/null",
|
"kubectl -n \"$namespace\" get pvc \"$cache_pvc\" -o json >/tmp/agentrun-gitmirror-cache.json 2>/dev/null",
|
||||||
"cache_exit=$?",
|
"cache_exit=$?",
|
||||||
|
"cache_mode=pvc",
|
||||||
|
"if [ -n \"$cache_host_path\" ]; then cache_mode=hostPath; fi",
|
||||||
"kubectl -n \"$namespace\" get deploy,svc,pvc -o name > /tmp/agentrun-gitmirror-names.txt 2>/dev/null",
|
"kubectl -n \"$namespace\" get deploy,svc,pvc -o name > /tmp/agentrun-gitmirror-names.txt 2>/dev/null",
|
||||||
"repo_path=\"/cache/${repository}.git\"",
|
"repo_path=\"/cache/${repository}.git\"",
|
||||||
"rm -f /tmp/agentrun-gitmirror-refs.txt",
|
"rm -f /tmp/agentrun-gitmirror-refs.txt",
|
||||||
"if [ \"$read_exit\" -eq 0 ]; then",
|
"if [ \"$read_exit\" -eq 0 ]; then",
|
||||||
" kubectl -n \"$namespace\" exec deploy/\"$read_deployment\" -- sh -lc 'repo_path=\"$1\"; source_branch=\"$2\"; gitops_branch=\"$3\"; printf \"sourceCommit=\"; git --git-dir=\"$repo_path\" rev-parse \"refs/heads/$source_branch\" 2>/dev/null || true; printf \"gitopsCommit=\"; git --git-dir=\"$repo_path\" rev-parse \"refs/heads/$gitops_branch\" 2>/dev/null || true' sh \"$repo_path\" \"$source_branch\" \"$gitops_branch\" > /tmp/agentrun-gitmirror-refs.txt 2>/dev/null",
|
" kubectl -n \"$namespace\" exec deploy/\"$read_deployment\" -- sh -lc 'repo_path=\"$1\"; source_branch=\"$2\"; gitops_branch=\"$3\"; printf \"sourceCommit=\"; git --git-dir=\"$repo_path\" rev-parse \"refs/heads/$source_branch\" 2>/dev/null || true; printf \"gitopsCommit=\"; git --git-dir=\"$repo_path\" rev-parse \"refs/heads/$gitops_branch\" 2>/dev/null || true' sh \"$repo_path\" \"$source_branch\" \"$gitops_branch\" > /tmp/agentrun-gitmirror-refs.txt 2>/dev/null",
|
||||||
"fi",
|
"fi",
|
||||||
"NAMESPACE=\"$namespace\" READ_EXIT=\"$read_exit\" WRITE_EXIT=\"$write_exit\" CACHE_EXIT=\"$cache_exit\" REPOSITORY=\"$repository\" SOURCE_BRANCH=\"$source_branch\" GITOPS_BRANCH=\"$gitops_branch\" REPOSITORIES_JSON=\"$repositories_json\" node <<'NODE'",
|
"NAMESPACE=\"$namespace\" READ_EXIT=\"$read_exit\" WRITE_EXIT=\"$write_exit\" CACHE_EXIT=\"$cache_exit\" CACHE_MODE=\"$cache_mode\" CACHE_HOST_PATH=\"$cache_host_path\" REPOSITORY=\"$repository\" SOURCE_BRANCH=\"$source_branch\" GITOPS_BRANCH=\"$gitops_branch\" REPOSITORIES_JSON=\"$repositories_json\" node <<'NODE'",
|
||||||
"const fs = require('node:fs');",
|
"const fs = require('node:fs');",
|
||||||
"const repositories = JSON.parse(process.env.REPOSITORIES_JSON || '[]');",
|
"const repositories = JSON.parse(process.env.REPOSITORIES_JSON || '[]');",
|
||||||
"let names = ''; try { names = fs.readFileSync('/tmp/agentrun-gitmirror-names.txt', 'utf8'); } catch {}",
|
"let names = ''; try { names = fs.readFileSync('/tmp/agentrun-gitmirror-names.txt', 'utf8'); } catch {}",
|
||||||
@@ -627,12 +630,17 @@ export function yamlLaneGitMirrorStatusScript(spec: AgentRunLaneSpec): string {
|
|||||||
"const readReady = process.env.READ_EXIT === '0';",
|
"const readReady = process.env.READ_EXIT === '0';",
|
||||||
"const writeReady = process.env.WRITE_EXIT === '0';",
|
"const writeReady = process.env.WRITE_EXIT === '0';",
|
||||||
"const cachePvcExists = process.env.CACHE_EXIT === '0';",
|
"const cachePvcExists = process.env.CACHE_EXIT === '0';",
|
||||||
|
"const cacheMode = process.env.CACHE_MODE || 'pvc';",
|
||||||
|
"const cacheReady = cacheMode === 'hostPath' ? true : cachePvcExists;",
|
||||||
"console.log(JSON.stringify({",
|
"console.log(JSON.stringify({",
|
||||||
" ok: readReady && writeReady && cachePvcExists,",
|
" ok: readReady && writeReady && cacheReady,",
|
||||||
" namespace: process.env.NAMESPACE,",
|
" namespace: process.env.NAMESPACE,",
|
||||||
" readReady,",
|
" readReady,",
|
||||||
" writeReady,",
|
" writeReady,",
|
||||||
|
" cacheMode,",
|
||||||
|
" cacheReady,",
|
||||||
" cachePvcExists,",
|
" cachePvcExists,",
|
||||||
|
" cacheHostPath: process.env.CACHE_HOST_PATH || null,",
|
||||||
" resources: names.split(/\\r?\\n/).filter(Boolean).slice(0, 40),",
|
" resources: names.split(/\\r?\\n/).filter(Boolean).slice(0, 40),",
|
||||||
" repository: process.env.REPOSITORY,",
|
" repository: process.env.REPOSITORY,",
|
||||||
" sourceBranch: process.env.SOURCE_BRANCH,",
|
" sourceBranch: process.env.SOURCE_BRANCH,",
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ export function isCaptureResult(value: unknown): value is SshCaptureResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isAgentRunPipelineRunName(value: string): boolean {
|
export function isAgentRunPipelineRunName(value: string): boolean {
|
||||||
return /^agentrun-v[0-9]+-ci-[0-9a-f]{12,40}(?:-[a-z0-9-]+)?$/u.test(value);
|
return /^agentrun-[a-z0-9-]*ci-[0-9a-f]{12,40}(?:-[a-z0-9-]+)?$/u.test(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function captureJsonPayload(result: SshCaptureResult): Record<string, unknown> {
|
export function captureJsonPayload(result: SshCaptureResult): Record<string, unknown> {
|
||||||
|
|||||||
Reference in New Issue
Block a user