diff --git a/terraform/scripts/stage_talos_image.py b/terraform/scripts/stage_talos_image.py index dada3b3..1e01815 100644 --- a/terraform/scripts/stage_talos_image.py +++ b/terraform/scripts/stage_talos_image.py @@ -53,6 +53,7 @@ def ensure_image(base_url, token, node, storage, image_url, filename, network_co if network_config_path: build_custom_iso(base_url, token, node, storage, source_filename, filename, network_config_path) + wait_for_storage_content(base_url, token, node, storage, filename) response = api_request(base_url, token, "GET", content_path) for item in response.get("data", []): @@ -79,6 +80,16 @@ def wait_for_task(base_url, token, node, upid): raise RuntimeError("timed out waiting for ISO download task to finish") +def wait_for_storage_content(base_url, token, node, storage, filename): + content_path = f"/api2/json/nodes/{node}/storage/{storage}/content" + for _ in range(180): + response = api_request(base_url, token, "GET", content_path) + if any(item.get("volid", "").endswith(filename) for item in response.get("data", [])): + return + time.sleep(2) + raise RuntimeError(f"timed out waiting for {filename} to appear in {node}/{storage}") + + def detect_proxmox_iso_dir(storage): candidates = [ Path("/var/lib/vz/template/iso"),