From 659d1c6148af55a55f891251bac27367a201179a Mon Sep 17 00:00:00 2001 From: Codex Date: Sat, 16 May 2026 15:59:16 +0000 Subject: [PATCH] fix k3s image import deployment timeout --- scripts/src/deploy.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/src/deploy.ts b/scripts/src/deploy.ts index 036ca32c..a539e2e9 100644 --- a/scripts/src/deploy.ts +++ b/scripts/src/deploy.ts @@ -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 };