fix: recover hwlab git mirror flush partial success
This commit is contained in:
@@ -2266,12 +2266,24 @@ function nodeRuntimeGitMirrorRun(scoped: ReturnType<typeof parseNodeScopedDelega
|
||||
].join("\n"),
|
||||
].join("\n");
|
||||
const result = runNodeK3sScript(spec, script, scoped.timeoutSeconds);
|
||||
const partialSuccess = nodeRuntimeGitMirrorFlushPartialSuccess(scoped, mirror, result);
|
||||
const fallback = scoped.action === "sync" && !scoped.dryRun && !isCommandSuccess(result) && nodeRuntimeGitMirrorSyncFallbackAllowed(result)
|
||||
? nodeRuntimeGitMirrorSyncFallback(scoped.spec, mirror, scoped.timeoutSeconds)
|
||||
: null;
|
||||
const actionSucceeded = isCommandSuccess(result) || fallback?.ok === true;
|
||||
const status = scoped.dryRun || !actionSucceeded ? undefined : nodeRuntimeGitMirrorStatus({ ...scoped, action: "status", dryRun: true, confirm: false });
|
||||
const partialSuccess = nodeRuntimeGitMirrorFlushPartialSuccess(scoped, mirror, result);
|
||||
const partialSuccessRecovery = partialSuccess !== null && !scoped.dryRun
|
||||
? nodeRuntimeGitMirrorRun({ ...scoped, domain: "git-mirror", action: "sync", confirm: true, dryRun: false, wait: true })
|
||||
: null;
|
||||
const partialSuccessRecoveryStatus = record(partialSuccessRecovery?.status);
|
||||
const partialSuccessRecovered = partialSuccess !== null
|
||||
&& partialSuccessRecovery?.ok === true
|
||||
&& Object.keys(partialSuccessRecoveryStatus).length > 0
|
||||
&& !nodeRuntimeGitMirrorNeedsFlush(partialSuccessRecoveryStatus);
|
||||
const actionSucceeded = isCommandSuccess(result) || fallback?.ok === true || partialSuccessRecovered;
|
||||
const status = scoped.dryRun || !actionSucceeded
|
||||
? undefined
|
||||
: partialSuccessRecovered
|
||||
? partialSuccessRecovery?.status
|
||||
: nodeRuntimeGitMirrorStatus({ ...scoped, action: "status", dryRun: true, confirm: false });
|
||||
return {
|
||||
ok: actionSucceeded && (status === undefined || status.ok === true),
|
||||
command: `hwlab nodes git-mirror ${scoped.action} --node ${scoped.node} --lane ${scoped.lane}`,
|
||||
@@ -2286,12 +2298,18 @@ function nodeRuntimeGitMirrorRun(scoped: ReturnType<typeof parseNodeScopedDelega
|
||||
fallback: fallback ?? undefined,
|
||||
status,
|
||||
partialSuccess: partialSuccess?.partialSuccess ?? undefined,
|
||||
partialSuccessRecovered: partialSuccessRecovered ? true : undefined,
|
||||
recovery: partialSuccess ?? undefined,
|
||||
postPushRecovery: partialSuccessRecovery === null ? undefined : compactNodeRuntimeGitMirrorRun(partialSuccessRecovery),
|
||||
degradedReason: partialSuccess !== null
|
||||
? "node-runtime-git-mirror-flush-post-push-fetch-failed"
|
||||
? partialSuccessRecovered
|
||||
? undefined
|
||||
: "node-runtime-git-mirror-flush-post-push-fetch-failed"
|
||||
: actionSucceeded ? status?.ok === false ? "node-runtime-git-mirror-status-failed-after-action" : undefined : fallback === null ? `node-runtime-git-mirror-${scoped.action}-failed` : "node-runtime-git-mirror-sync-fallback-failed",
|
||||
next: partialSuccess !== null
|
||||
? partialSuccess.next
|
||||
? partialSuccessRecovered
|
||||
? { status: `bun scripts/cli.ts hwlab nodes git-mirror status --node ${scoped.node} --lane ${scoped.lane}` }
|
||||
: partialSuccess.next
|
||||
: scoped.dryRun
|
||||
? { run: `bun scripts/cli.ts hwlab nodes git-mirror ${scoped.action} --node ${scoped.node} --lane ${scoped.lane} --confirm` }
|
||||
: { status: `bun scripts/cli.ts hwlab nodes git-mirror status --node ${scoped.node} --lane ${scoped.lane}` },
|
||||
|
||||
Reference in New Issue
Block a user