fix: provisioner now extracts archives and discovers disks before conversion

The job submission receives the original filename (e.g. Debian_13_VMG.7z)
but qemu-img convert needs the actual VMDK path inside the archive.
Now reuse extract_if_needed() + discover_disk() from converter module
to locate the real disk image before conversion.
This commit is contained in:
Claus Lohmar 2026-07-21 19:11:19 +00:00
parent 56131d6346
commit affcde7afb

View file

@ -24,10 +24,10 @@ from models import (
JobStatus,
DiskType,
)
from converter import extract_if_needed, discover_disk
logger = logging.getLogger("backend.provisioner")
STAGING_IN = Path("/mnt/converter/in")
STAGING_OUT = Path("/mnt/converter/out")
# In-memory job tracking — survives as long as the process runs
@ -164,13 +164,15 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
output_path = out_dir / f"vm-{vmid}-disk-{idx}.qcow2"
if spec.disk_type == DiskType.IMAGE_FILE:
source_path = STAGING_IN / spec.source_filename
if not source_path.exists():
raise FileNotFoundError(f"Source file not found: {source_path}")
# Extract archive if needed, then locate the actual disk image
source = extract_if_needed(spec.source_filename)
disk = discover_disk(source)
source_path = disk.path
logger.info("Disk %d: source=%s format=%s size=%.1f GiB",
idx, source_path, disk.format, disk.size_gb)
logger.info("Converting disk %d: %s%s", idx, source_path, output_path)
_run(["qemu-img", "convert",
"-f", spec.format.value if spec.format else "vmdk",
"-f", disk.format,
"-O", "qcow2",
str(source_path), str(output_path)],
timeout=7200)