fix: prioritize branch follower closeout scheduling
This commit is contained in:
@@ -35,6 +35,7 @@ import { runBranchFollowerTaskRunDrillDown } from "./cicd-taskrun-drilldown";
|
||||
import { runBranchFollowerJobDrillDown, runBranchFollowerRuntimeDrillDown } from "./cicd-job-runtime-drilldown";
|
||||
import { runBranchFollowerGate } from "./cicd-gates";
|
||||
import { attachReconcileTimeline, compactReconcileTimeline, finishReconcileStep, finishReconcileTimeline, startReconcileStep, startReconcileTimeline } from "./cicd-reconcile-timeline";
|
||||
import { orderFollowersForControllerCloseout, shouldYieldAfterAutomaticTrigger } from "./cicd-reconcile-scheduler";
|
||||
import type { AdapterSummary, BranchFollowerAction, BranchFollowerDebugStep, BranchFollowerGate, BranchFollowerPhase, BranchFollowerRegistry, ControllerSpec, FollowerSpec, FollowerState, K8sFollowerStateRead, K8sStateRead, NativeCloseoutWaitResult, NativeK8sJobResult, NativeStatusSpec, NativeWorkloadSpec, OutputMode, ParsedOptions, StageTiming, TriggerResult } from "./cicd-types";
|
||||
import {
|
||||
arrayField,
|
||||
@@ -707,10 +708,13 @@ async function runOnce(registry: BranchFollowerRegistry, options: ParsedOptions)
|
||||
const stateReadStep = startReconcileStep(reconcileTimeline, "*", "state-read");
|
||||
const previous = readK8sState(registry, options);
|
||||
finishReconcileStep(stateReadStep, { status: previous.ok ? "ok" : "degraded", object: registry.controller.stateConfigMapName, reason: previous.errors.join("; ") });
|
||||
const scheduled = orderFollowersForControllerCloseout(selected, previous.stateByFollower);
|
||||
reconcileTimeline.followerCount = scheduled.length;
|
||||
reconcileTimeline.followers = scheduled.map((follower) => follower.id).slice(0, 8);
|
||||
const results: FollowerState[] = [];
|
||||
const stateWriteWarnings: string[] = [];
|
||||
const stateWrites: Record<string, unknown>[] = [];
|
||||
for (const follower of selected) {
|
||||
for (const follower of scheduled) {
|
||||
const oldState = previous.stateByFollower[follower.id] ?? {};
|
||||
const statusReadStep = startReconcileStep(reconcileTimeline, follower.id, "status-read");
|
||||
const live = await readAdapterStatus(registry, follower, options);
|
||||
@@ -732,6 +736,10 @@ async function runOnce(registry: BranchFollowerRegistry, options: ParsedOptions)
|
||||
}
|
||||
}
|
||||
results.push(state);
|
||||
if (shouldYieldAfterAutomaticTrigger(options, state)) {
|
||||
stateWriteWarnings.push(`controller yielded after triggering ${follower.id}; remaining followers will be reconciled by the next loop`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
finishReconcileTimeline(reconcileTimeline);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user