diff --git a/scripts/src/agentrun/control-plane.ts b/scripts/src/agentrun/control-plane.ts index dcbb0583..b5eb9fc8 100644 --- a/scripts/src/agentrun/control-plane.ts +++ b/scripts/src/agentrun/control-plane.ts @@ -372,7 +372,7 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio ...(sourcePayload.workspaceClean === true || sourcePayload.workspaceExists !== true ? [] : ["source-worktree-dirty"]), ...(mirrorPayload.readReady === true ? [] : ["git-mirror-read-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"]), ...(pipeline.exists === true ? [] : ["pipeline-missing"]), ...(pipelineRunName !== null && pipelineRunStatus.exists !== true ? ["pipelinerun-missing"] : []), @@ -432,7 +432,10 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio const compactGitMirrorStatus = { readReady: mirrorPayload.readReady ?? false, writeReady: mirrorPayload.writeReady ?? false, + cacheMode: mirrorPayload.cacheMode ?? null, + cacheReady: mirrorPayload.cacheReady ?? false, cachePvcExists: mirrorPayload.cachePvcExists ?? false, + cacheHostPath: mirrorPayload.cacheHostPath ?? null, sourceCommit: mirrorSourceCommit, gitopsCommit: expectedGitopsRevision, alreadySynced: mirrorAlreadySynced, @@ -496,7 +499,10 @@ export async function statusYamlLane(config: UniDeskConfig, options: StatusOptio gitMirror: { readReady: mirrorPayload.readReady ?? false, writeReady: mirrorPayload.writeReady ?? false, + cacheMode: mirrorPayload.cacheMode ?? null, + cacheReady: mirrorPayload.cacheReady ?? false, cachePvcExists: mirrorPayload.cachePvcExists ?? false, + cacheHostPath: mirrorPayload.cacheHostPath ?? null, repositoryCount: Array.isArray(mirrorPayload.repositories) ? mirrorPayload.repositories.length : null, sourceCommit: mirrorSourceCommit, gitopsCommit: expectedGitopsRevision, diff --git a/scripts/src/agentrun/entry.ts b/scripts/src/agentrun/entry.ts index 9694f40f..0ad087d7 100644 --- a/scripts/src/agentrun/entry.ts +++ b/scripts/src/agentrun/entry.ts @@ -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 status", "bun scripts/cli.ts agentrun control-plane status --full", - "bun scripts/cli.ts agentrun control-plane status --pipeline-run agentrun-vNN-ci-", + "bun scripts/cli.ts agentrun control-plane status --pipeline-run ", "bun scripts/cli.ts agentrun control-plane status --source-commit ", "bun scripts/cli.ts agentrun control-plane expose --dry-run", "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 trigger-current --node D601 --lane v02 --dry-run", " bun scripts/cli.ts agentrun control-plane status", - " bun scripts/cli.ts agentrun control-plane status --pipeline-run agentrun-vNN-ci-", + " bun scripts/cli.ts agentrun control-plane status --pipeline-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 cleanup-runners --node D601 --lane v02 --dry-run", diff --git a/scripts/src/agentrun/options.ts b/scripts/src/agentrun/options.ts index e3e11f85..49183de2 100644 --- a/scripts/src/agentrun/options.ts +++ b/scripts/src/agentrun/options.ts @@ -352,7 +352,7 @@ export function parseStatusOptions(args: string[]): StatusOptions { if (arg === "--pipeline-run") { const value = args[index + 1]; 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; index += 1; continue; diff --git a/scripts/src/agentrun/secrets.ts b/scripts/src/agentrun/secrets.ts index f8f17df2..28706fef 100644 --- a/scripts/src/agentrun/secrets.ts +++ b/scripts/src/agentrun/secrets.ts @@ -602,6 +602,7 @@ export function yamlLaneGitMirrorStatusScript(spec: AgentRunLaneSpec): string { `read_service=${shQuote(spec.gitMirror.readService)}`, `write_service=${shQuote(spec.gitMirror.writeService)}`, `cache_pvc=${shQuote(spec.gitMirror.cachePvc)}`, + `cache_host_path=${spec.gitMirror.cacheHostPath === null ? "''" : shQuote(spec.gitMirror.cacheHostPath)}`, `repository=${shQuote(spec.source.repository)}`, `source_branch=${shQuote(spec.source.branch)}`, `gitops_branch=${shQuote(spec.gitops.branch)}`, @@ -612,13 +613,15 @@ export function yamlLaneGitMirrorStatusScript(spec: AgentRunLaneSpec): string { "write_exit=$?", "kubectl -n \"$namespace\" get pvc \"$cache_pvc\" -o json >/tmp/agentrun-gitmirror-cache.json 2>/dev/null", "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", "repo_path=\"/cache/${repository}.git\"", "rm -f /tmp/agentrun-gitmirror-refs.txt", "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", "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 repositories = JSON.parse(process.env.REPOSITORIES_JSON || '[]');", "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 writeReady = process.env.WRITE_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({", - " ok: readReady && writeReady && cachePvcExists,", + " ok: readReady && writeReady && cacheReady,", " namespace: process.env.NAMESPACE,", " readReady,", " writeReady,", + " cacheMode,", + " cacheReady,", " cachePvcExists,", + " cacheHostPath: process.env.CACHE_HOST_PATH || null,", " resources: names.split(/\\r?\\n/).filter(Boolean).slice(0, 40),", " repository: process.env.REPOSITORY,", " sourceBranch: process.env.SOURCE_BRANCH,", diff --git a/scripts/src/agentrun/utils.ts b/scripts/src/agentrun/utils.ts index 36ee24a5..a6ff24fb 100644 --- a/scripts/src/agentrun/utils.ts +++ b/scripts/src/agentrun/utils.ts @@ -338,7 +338,7 @@ export function isCaptureResult(value: unknown): value is SshCaptureResult { } 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 {