fix: refresh argo during follower closeout
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user