fix: avoid blocking v02 mirror apply on temp render drift
This commit is contained in:
+17
-18
@@ -716,7 +716,7 @@ function runControlPlaneCleanup(options: G14ControlPlaneOptions): Record<string,
|
||||
};
|
||||
}
|
||||
|
||||
function runV02RenderCheck(sourceCommit: string): CommandJsonResult {
|
||||
function runV02RenderToTemp(sourceCommit: string): CommandJsonResult {
|
||||
const renderDir = v02RenderDir(sourceCommit);
|
||||
return v02WorkspaceScript([
|
||||
"set -eu",
|
||||
@@ -727,7 +727,6 @@ function runV02RenderCheck(sourceCommit: string): CommandJsonResult {
|
||||
`rm -rf ${shellQuote(renderDir)}`,
|
||||
`mkdir -p ${shellQuote(renderDir)}`,
|
||||
`node scripts/g14-gitops-render.mjs --lane v02 --source-revision ${shellQuote(sourceCommit)} --out ${shellQuote(renderDir)}`,
|
||||
`node scripts/g14-gitops-render.mjs --lane v02 --source-revision ${shellQuote(sourceCommit)} --out ${shellQuote(renderDir)} --check`,
|
||||
].join("\n"), 180_000);
|
||||
}
|
||||
|
||||
@@ -756,15 +755,15 @@ function applyV02ControlPlaneFiles(sourceCommit: string, dryRun: boolean, timeou
|
||||
}
|
||||
|
||||
function refreshV02ControlPlaneBeforeTrigger(sourceCommit: string, timeoutSeconds: number): Record<string, unknown> {
|
||||
const renderCheck = runV02RenderCheck(sourceCommit);
|
||||
if (!isCommandSuccess(renderCheck)) {
|
||||
const render = runV02RenderToTemp(sourceCommit);
|
||||
if (!isCommandSuccess(render)) {
|
||||
return {
|
||||
ok: false,
|
||||
phase: "source-render-check",
|
||||
phase: "source-render",
|
||||
sourceCommit,
|
||||
renderDir: v02RenderDir(sourceCommit),
|
||||
renderCheck,
|
||||
degradedReason: "control-plane-render-check-failed",
|
||||
render,
|
||||
degradedReason: "control-plane-render-failed",
|
||||
};
|
||||
}
|
||||
const apply = applyV02ControlPlaneFiles(sourceCommit, false, timeoutSeconds);
|
||||
@@ -774,7 +773,7 @@ function refreshV02ControlPlaneBeforeTrigger(sourceCommit: string, timeoutSecond
|
||||
phase: "control-plane-refresh",
|
||||
sourceCommit,
|
||||
renderDir: v02RenderDir(sourceCommit),
|
||||
renderCheck: commandData(renderCheck),
|
||||
render: commandData(render),
|
||||
apply,
|
||||
cleanupObsoleteCronJobs,
|
||||
degradedReason: !isCommandSuccess(apply)
|
||||
@@ -954,14 +953,14 @@ function runV02ControlPlane(options: G14ControlPlaneOptions): Record<string, unk
|
||||
if (options.action === "runtime-migration") return runV02RuntimeMigration(options, sourceCommit);
|
||||
if (options.action === "status") return v02ControlPlaneStatus(sourceCommit);
|
||||
if (options.action === "apply") {
|
||||
const renderCheck = runV02RenderCheck(sourceCommit);
|
||||
if (!isCommandSuccess(renderCheck)) {
|
||||
const render = runV02RenderToTemp(sourceCommit);
|
||||
if (!isCommandSuccess(render)) {
|
||||
return {
|
||||
ok: false,
|
||||
command: `hwlab g14 control-plane ${options.action} --lane v02`,
|
||||
phase: "source-render-check",
|
||||
phase: "source-render",
|
||||
sourceCommit,
|
||||
renderCheck,
|
||||
render,
|
||||
};
|
||||
}
|
||||
const apply = applyV02ControlPlaneFiles(sourceCommit, options.dryRun, options.timeoutSeconds);
|
||||
@@ -972,7 +971,7 @@ function runV02ControlPlane(options: G14ControlPlaneOptions): Record<string, unk
|
||||
mode: options.dryRun ? "dry-run" : "confirmed-apply",
|
||||
sourceCommit,
|
||||
renderDir: v02RenderDir(sourceCommit),
|
||||
renderCheck: commandData(renderCheck),
|
||||
render: commandData(render),
|
||||
apply,
|
||||
cleanupObsoleteCronJobs: options.dryRun ? deleteV02ObsoleteCronJobs(true) : deleteV02ObsoleteCronJobs(false),
|
||||
status: v02ControlPlaneStatus(sourceCommit),
|
||||
@@ -1384,14 +1383,14 @@ function runGitMirrorApply(options: G14GitMirrorOptions): Record<string, unknown
|
||||
if (sourceCommit === null) {
|
||||
return { ok: false, command: "hwlab g14 git-mirror apply", degradedReason: "v02-head-unresolved", workspace: V02_WORKSPACE };
|
||||
}
|
||||
const renderCheck = runV02RenderCheck(sourceCommit);
|
||||
if (!isCommandSuccess(renderCheck)) {
|
||||
const render = runV02RenderToTemp(sourceCommit);
|
||||
if (!isCommandSuccess(render)) {
|
||||
return {
|
||||
ok: false,
|
||||
command: "hwlab g14 git-mirror apply",
|
||||
phase: "source-render-check",
|
||||
phase: "source-render",
|
||||
sourceCommit,
|
||||
renderCheck,
|
||||
render,
|
||||
};
|
||||
}
|
||||
const apply = applyGitMirrorManifestFile(sourceCommit, options.dryRun, options.timeoutSeconds);
|
||||
@@ -1411,7 +1410,7 @@ function runGitMirrorApply(options: G14GitMirrorOptions): Record<string, unknown
|
||||
mode: options.dryRun ? "dry-run" : "confirmed-apply",
|
||||
sourceCommit,
|
||||
manifest: `${v02RenderDir(sourceCommit)}/devops-infra/git-mirror.yaml`,
|
||||
renderCheck: commandData(renderCheck),
|
||||
render: commandData(render),
|
||||
apply,
|
||||
cleanupLegacyCronJob,
|
||||
status: runGitMirrorStatus(),
|
||||
|
||||
Reference in New Issue
Block a user