fix: refresh argo during follower closeout

This commit is contained in:
Codex
2026-07-03 19:06:04 +00:00
parent 979bd33a72
commit 4d370bd0fb
2 changed files with 25 additions and 0 deletions
+23
View File
@@ -858,6 +858,10 @@ async function decideAndMaybeTrigger(
}
if (options.dryRun && phase === "PendingTrigger") decision = `${decision}; dry-run did not trigger`;
if (shouldRefreshAutomaticCloseout(follower, observedSha, live, phase, options)) {
const refresh = runNativeArgoRefresh(follower.nativeStatus.argo as NonNullable<NativeStatusSpec["argo"]>);
if (refresh.exitCode !== 0) warnings.push(`argo refresh failed: ${redactText(tailText(refresh.stderr || refresh.stdout, 300))}`);
}
const statePipelineRun = stringOrNull(triggerCommand?.pipelineRun) ?? live.pipelineRun;
return {
@@ -904,6 +908,25 @@ async function decideAndMaybeTrigger(
};
}
function shouldRefreshAutomaticCloseout(
follower: FollowerSpec,
observedSha: string | null,
live: AdapterSummary,
phase: BranchFollowerPhase,
options: ParsedOptions,
): boolean {
if (!options.inCluster || !options.confirm || options.wait || options.dryRun) return false;
if (phase !== "ClosingOut" || observedSha === null || follower.nativeStatus.argo === null) return false;
const payload = asOptionalRecord(live.payload);
const tekton = asOptionalRecord(payload?.tekton);
if (tekton?.succeeded !== true) return false;
const argo = asOptionalRecord(payload?.argo);
const runtime = asOptionalRecord(payload?.runtime);
const argoReady = argo?.ready === true;
const runtimeAligned = runtime?.aligned === true;
return !argoReady || !runtimeAligned || live.targetSha !== observedSha;
}
async function executeTrigger(registry: BranchFollowerRegistry, follower: FollowerSpec, observedSha: string | null, options: ParsedOptions): Promise<TriggerResult> {
const spec = follower.commands.trigger;
const timeoutSeconds = options.timeoutSeconds ?? spec.timeoutSeconds;