fix: resume native agentrun follower stages
This commit is contained in:
+14
-5
@@ -1021,7 +1021,8 @@ async function decideAndMaybeTrigger(
|
||||
if (!live.ok) warnings.push(`status command failed: exitCode=${live.exitCode}${live.timedOut ? " timedOut=true" : ""}`);
|
||||
const observedSha = live.observedSha;
|
||||
let targetSha = live.targetSha;
|
||||
const previousLastTriggered = stringOrNull(previous.lastTriggeredSha);
|
||||
const previousPhase = stringOrNull(previous.phase);
|
||||
const previousLastTriggered = previousPhase === "Failed" ? null : stringOrNull(previous.lastTriggeredSha);
|
||||
const previousInFlight = stringOrNull(previous.inFlightJob);
|
||||
const previousLastSucceeded = stringOrNull(previous.lastSucceededSha);
|
||||
const previousObserved = stringOrNull(recordAt(previous, ["source"])?.observedSha);
|
||||
@@ -1205,7 +1206,8 @@ async function executeNativeAgentRunTrigger(registry: BranchFollowerRegistry, fo
|
||||
const { configPath, spec } = resolveAgentRunLaneTarget({ node: follower.target.node, lane: follower.target.lane });
|
||||
const startedAt = Date.now();
|
||||
const stageRef = `${follower.source.snapshotPrefix.replace(/\/+$/u, "")}/${observedSha}`;
|
||||
const buildJob = `agentrun-bf-build-${spec.nodeId.toLowerCase()}-${observedSha.slice(0, 12)}-${Date.now().toString(36)}`.slice(0, 63);
|
||||
const jobPrefix = `agentrun-bf-${spec.nodeId.toLowerCase()}-${spec.lane}`;
|
||||
const buildJob = `${jobPrefix}-build-${observedSha.slice(0, 12)}`.slice(0, 63);
|
||||
const build = runNativeK8sJob(spec.ci.namespace, buildJob, yamlLaneK3sBuildImageJobManifest(spec, observedSha, buildJob), Math.min(remainingSeconds(startedAt, timeoutSeconds), Math.max(60, spec.deployment.manager.imageBuild.timeoutSeconds)), "buildkit");
|
||||
const buildPayload = yamlLaneGitopsPublishPayloadFromProbe({ logsTail: stringOrNull(build.logsTail) ?? "" });
|
||||
const digest = stringOrNull(buildPayload.digest);
|
||||
@@ -1215,13 +1217,13 @@ async function executeNativeAgentRunTrigger(registry: BranchFollowerRegistry, fo
|
||||
}
|
||||
const image = agentRunImageArtifact(spec, { sourceCommit: observedSha, envIdentity, digest, status: stringOrNull(buildPayload.status) ?? "built" });
|
||||
const renderedFiles = renderAgentRunGitopsFiles(spec, { sourceCommit: observedSha, image });
|
||||
const publishJob = `agentrun-bf-gitops-${spec.nodeId.toLowerCase()}-${observedSha.slice(0, 12)}-${Date.now().toString(36)}`.slice(0, 63);
|
||||
const publishJob = `${jobPrefix}-gitops-${observedSha.slice(0, 12)}`.slice(0, 63);
|
||||
const publish = runNativeK8sJob(spec.gitMirror.namespace, publishJob, yamlLaneGitopsPublishJobManifest(spec, renderedFiles, publishJob), remainingSeconds(startedAt, timeoutSeconds), "publish");
|
||||
const publishPayload = yamlLaneGitopsPublishPayloadFromProbe({ logsTail: stringOrNull(publish.logsTail) ?? "" });
|
||||
if (!publish.ok || publishPayload.ok === false || stringOrNull(publishPayload.gitopsCommit) === null) {
|
||||
return nativeAgentRunStageFailure(follower, observedSha, "gitops-publish", publishJob, publish, publishPayload, "native AgentRun GitOps publish failed");
|
||||
}
|
||||
const flushJob = `${spec.gitMirror.flushJobPrefix}-${Date.now().toString(36)}-bf`.slice(0, 63);
|
||||
const flushJob = `${jobPrefix}-flush-${observedSha.slice(0, 12)}`.slice(0, 63);
|
||||
const flush = runNativeK8sJob(spec.gitMirror.namespace, flushJob, yamlLaneGitMirrorJobManifest(spec, "flush", flushJob), remainingSeconds(startedAt, timeoutSeconds), "flush");
|
||||
if (!flush.ok) {
|
||||
return nativeAgentRunStageFailure(follower, observedSha, "git-mirror-flush", flushJob, flush, {}, "native AgentRun git-mirror flush failed");
|
||||
@@ -1276,10 +1278,17 @@ function nativeAgentRunStageFailure(
|
||||
payload: Record<string, unknown>,
|
||||
message: string,
|
||||
): TriggerResult {
|
||||
const detail = [
|
||||
message,
|
||||
job.timedOut ? "timedOut=true" : null,
|
||||
job.conditionReason === null ? null : `reason=${job.conditionReason}`,
|
||||
job.conditionMessage === null ? null : `condition=${job.conditionMessage}`,
|
||||
job.logsTail === null ? null : `logs=${tailText(job.logsTail, 500)}`,
|
||||
].filter((item): item is string => item !== null).join("; ");
|
||||
return {
|
||||
ok: false,
|
||||
completed: false,
|
||||
message,
|
||||
message: detail,
|
||||
jobId: jobName,
|
||||
command: {
|
||||
mode: "k8s-native-job",
|
||||
|
||||
Reference in New Issue
Block a user