fix: flush AgentRun PaC GitOps mirror on closeout
This commit is contained in:
@@ -5,6 +5,7 @@ import type { UniDeskConfig } from "./config";
|
||||
import { rootPath } from "./config";
|
||||
import { parseNodeScopedDelegatedOptions } from "./hwlab-node/plan";
|
||||
import { nodeRuntimeEnsureGitMirrorFlushed } from "./hwlab-node/status";
|
||||
import { runGitMirrorJob as runAgentRunGitMirrorJob } from "./agentrun/rest-bridge";
|
||||
import type { RenderedCliResult } from "./output";
|
||||
import {
|
||||
capture,
|
||||
@@ -543,7 +544,7 @@ async function closeout(config: UniDeskConfig, options: CloseoutOptions): Promis
|
||||
const observedSourceCommit = stringValue(latest.sourceCommit) !== "-" ? stringValue(latest.sourceCommit) : stringValue(diagnostics.sourceCommit);
|
||||
const sourceMatched = options.sourceCommit === null || observedSourceCommit === options.sourceCommit;
|
||||
const baseReady = current.ok === true && sourceMatched;
|
||||
const gitOpsMirrorFlush = runCloseoutGitOpsMirrorFlush(pac, consumer, latest, baseReady, observedSourceCommit);
|
||||
const gitOpsMirrorFlush = await runCloseoutGitOpsMirrorFlush(config, pac, consumer, latest, baseReady, observedSourceCommit);
|
||||
const gitOpsMirrorFlushReady = record(gitOpsMirrorFlush).ok !== false;
|
||||
const ready = baseReady && gitOpsMirrorFlushReady;
|
||||
return {
|
||||
@@ -1351,7 +1352,7 @@ function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function runCloseoutGitOpsMirrorFlush(pac: PacConfig, consumer: PacConsumer, latest: Record<string, unknown>, baseReady: boolean, observedSourceCommit: string): Record<string, unknown> {
|
||||
async function runCloseoutGitOpsMirrorFlush(config: UniDeskConfig, pac: PacConfig, consumer: PacConsumer, latest: Record<string, unknown>, baseReady: boolean, observedSourceCommit: string): Promise<Record<string, unknown>> {
|
||||
const cfg = pac.closeout.gitOpsMirrorFlush;
|
||||
const configSource = `${configLabel}.closeout.gitOpsMirrorFlush`;
|
||||
const required = cfg.enabled && consumer.closeoutGitOpsMirrorFlush;
|
||||
@@ -1390,6 +1391,37 @@ function runCloseoutGitOpsMirrorFlush(pac: PacConfig, consumer: PacConsumer, lat
|
||||
valuesPrinted: false,
|
||||
};
|
||||
}
|
||||
if (consumer.id.startsWith("agentrun-")) {
|
||||
const progressLines: string[] = [];
|
||||
const flush = await captureStderrLines(progressLines, () => runAgentRunGitMirrorJob(config, "flush", {
|
||||
node: consumer.node,
|
||||
lane: consumer.lane,
|
||||
confirm: true,
|
||||
dryRun: false,
|
||||
wait: true,
|
||||
timeoutSeconds: cfg.waitTimeoutSeconds,
|
||||
}));
|
||||
return {
|
||||
ok: flush.ok === true,
|
||||
enabled: true,
|
||||
required: true,
|
||||
mode: stringValue(flush.mode, flush.ok === true ? "flushed" : "failed"),
|
||||
executed: flush.ok === true,
|
||||
sourceCommit: observedSourceCommit,
|
||||
pipelineRun,
|
||||
configSource,
|
||||
waitTimeoutSeconds: cfg.waitTimeoutSeconds,
|
||||
maxAttempts: cfg.maxAttempts,
|
||||
beforeSummary: record(record(flush.status).summary),
|
||||
afterSummary: record(record(flush.status).summary),
|
||||
jobName: flush.jobName ?? null,
|
||||
degradedReason: flush.ok === true ? undefined : "pac-closeout-agentrun-gitops-mirror-flush-failed",
|
||||
next: record(flush.next),
|
||||
flush,
|
||||
progressLines,
|
||||
valuesPrinted: false,
|
||||
};
|
||||
}
|
||||
const deadlineMs = Date.now() + (cfg.waitTimeoutSeconds * 1000);
|
||||
const scoped = parseNodeScopedDelegatedOptions("git-mirror", [
|
||||
"flush",
|
||||
|
||||
Reference in New Issue
Block a user