fix(vm-provision): say why a cloud-image download failed, drop its tmp
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m29s
driver / test (3.13) (pull_request) Successful in 1m26s
driver / test (3.12) (pull_request) Successful in 1m39s
driver / lowest (pull_request) Successful in 37s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m11s
CI / driver (pull_request) Successful in 3m19s
driver / publish (pull_request) Skipped

wget ran with -q, so a failure carried no reason, and a failed
download left its partial .tmp in the cache, taking the same space
again on every retry. wget now runs with -nv and the .tmp is removed
on failure, keeping wget's exit status.

Closes #3
This commit is contained in:
Christian Manivong committed 2026-11-01 21:57:36 +01:00
1 parent 10cf788b86
commit 9c7b64ba64
4 files changed
+68 -7

No files matched your search

+15 -6
View File
@@ -186,12 +186,7 @@ class ProxmoxVMProvisionMixin:
timeout=30,
)
if "EXISTS" not in exists:
_logger.info(f"Downloading cloud image {image_url} -> {local_path}")
self._run_node_command(
f"wget -q -O {local_path}.tmp '{image_url}' "
f"&& mv {local_path}.tmp {local_path}",
timeout=timeout,
)
self._fetch_image(image_url, local_path, timeout)
if not image_checksum:
return local_path
@@ -216,6 +211,20 @@ class ProxmoxVMProvisionMixin:
raise AssertionError("unreachable") # loop always returns or raises above
def _fetch_image(self, image_url: str, local_path: str, timeout: int) -> None:
"""Download *image_url* to *local_path* on the node, through a ``.tmp``.
wget runs with ``-nv`` so its reason ("No space left on device")
reaches the error, and a failed download leaves no partial ``.tmp``.
"""
_logger.info(f"Downloading cloud image {image_url} -> {local_path}")
tmp = f"{local_path}.tmp"
self._run_node_command(
f"wget -nv -O {tmp} '{image_url}' && mv {tmp} {local_path} "
f"|| {{ s=$?; rm -f {tmp}; exit $s; }}",
timeout=timeout,
)
def _cloud_image_on_node(self, image_url: str, image_checksum: str | None, timeout: int) -> str:
"""The node path of the image, downloaded, verified and unpacked.