From ae53d2fbd8b716ce06a7b0cadb0d2741f3136058 Mon Sep 17 00:00:00 2001 From: Claus Lohmar Date: Mon, 27 Jul 2026 08:57:58 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20disk=20resize=20now=20opt-in=20=E2=80=94?= =?UTF-8?q?=20pre-filled=20with=20current=20size,=20disabled=20by=20defaul?= =?UTF-8?q?t,=20checkbox=20to=20enable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Backend: None = keep current size (no auto-shrink); only resize when value explicitly provided - Frontend: Target Disk Size field shows detected size, disabled (not submitted) - Checkbox 'Enable disk resize' unlocks the field for editing --- backend/provisioner.py | 12 ++---------- frontend/templates/_analysis.html | 14 ++++++++------ frontend/templates/index.html | 12 ++++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/backend/provisioner.py b/backend/provisioner.py index 9e84c2f..a9a1c44 100644 --- a/backend/provisioner.py +++ b/backend/provisioner.py @@ -300,16 +300,8 @@ def _process_job(job_id: str, req: JobSubmissionRequest): target_gb = req.target_disk_size_gb if target_gb is None: - # Auto-shrink: 10% of virtual size, minimum 20 GB - auto_target = max(int(current_gb * 0.1), 20) - if current_gb > auto_target: - target_gb = auto_target - logger.info("Auto-shrink: %.1f GiB → %d GiB (10%% rule)", current_gb, target_gb) - else: - target_gb = int(round(current_gb)) + 1 - logger.info("Disk already <= target, no shrink needed") - - if target_gb < current_gb: + logger.info("Disk size not specified — keeping current (%.1f GiB)", current_gb) + elif target_gb < current_gb: _update_job(job_id, progress=60, message=f"Shrinking disk to {target_gb} GiB...") logger.info("Shrinking disk: %.1f GiB → %d GiB via virt-resize", current_gb, target_gb) diff --git a/frontend/templates/_analysis.html b/frontend/templates/_analysis.html index 4646fe5..97e7013 100644 --- a/frontend/templates/_analysis.html +++ b/frontend/templates/_analysis.html @@ -66,13 +66,15 @@
- - - {{ analysis.disk_size_gb }} GB detected. Auto-shrink to {{ (analysis.disk_size_gb * 0.1)|round(0)|int if (analysis.disk_size_gb * 0.1) > 20 else 20 }} GB if left blank.
+ + + + Default: {{ analysis.disk_size_gb }} GB (no resize). Check the box above to change. Warning: shrinking can break complex layouts (LVM, encryption). - If unsure, enter the full size ({{ analysis.disk_size_gb }} GB) to skip.
diff --git a/frontend/templates/index.html b/frontend/templates/index.html index 97c331e..08e8874 100644 --- a/frontend/templates/index.html +++ b/frontend/templates/index.html @@ -166,6 +166,18 @@ function showError(msg) { if (el) el.innerHTML += '
' + msg + '
'; } +function toggleDiskResize() { + var cb = document.getElementById('enable-resize'); + var inp = document.getElementById('target-disk-size'); + if (!cb || !inp) return; + if (cb.checked) { + inp.removeAttribute('disabled'); + inp.focus(); + } else { + inp.setAttribute('disabled', ''); + } +} + function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function startSession(e) {