fix k3s image import deployment timeout

This commit is contained in:
Codex
2026-05-16 15:59:16 +00:00
parent 6263f83926
commit 659d1c6148
+7 -2
View File
@@ -865,12 +865,17 @@ function ensureNativeK3sScript(): string {
function importK3sImageScript(service: UniDeskMicroserviceConfig): string {
const image = buildImageTag(service);
const archive = `/tmp/unidesk-${safeId(service.id)}-k3s-image.tar`;
return [
"set -euo pipefail",
...rootAccessPrelude(),
`image=${shellQuote(image)}`,
`archive=${shellQuote(archive)}`,
"docker image inspect \"$image\" >/dev/null",
`docker save "$image" | root_exec ctr --address ${shellQuote(nativeK3sCtrAddress)} -n k8s.io images import -`,
"rm -f \"$archive\"",
"docker save \"$image\" -o \"$archive\"",
`root_exec ctr --address ${shellQuote(nativeK3sCtrAddress)} -n k8s.io images import "$archive"`,
"rm -f \"$archive\"",
`root_exec ctr --address ${shellQuote(nativeK3sCtrAddress)} -n k8s.io images ls | grep -F "$image" || true`,
].join("\n");
}
@@ -1360,7 +1365,7 @@ async function applyOneService(config: UniDeskConfig, service: UniDeskMicroservi
if (service.deployment.mode === "k3sctl-managed") {
const nativeK3s = await step(config, service, "ensure-native-k3s", ensureNativeK3sScript(), "/home/ubuntu", 600_000, true);
if (!pushStep(steps, nativeK3s)) return { ok: false, serviceId: service.id, startedAt, finishedAt: nowIso(), resolvedCommit, before, steps };
const imageImport = await step(config, service, "import-k3s-image", importK3sImageScript(service), targetWorkDir(service), 180_000, true);
const imageImport = await step(config, service, "import-k3s-image", importK3sImageScript(service), targetWorkDir(service), Math.min(options.timeoutMs, 900_000), true);
if (!pushStep(steps, imageImport)) return { ok: false, serviceId: service.id, startedAt, finishedAt: nowIso(), resolvedCommit, before, steps };
const apply = await step(config, service, "kubectl-apply", applyK8sScript(service), targetWorkDir(service), 60_000, false);
if (!pushStep(steps, apply)) return { ok: false, serviceId: service.id, startedAt, finishedAt: nowIso(), resolvedCommit, before, steps };