1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 00:46:05 +00:00

fix(instances): a disk on an LVM pool is not resized, the page says so instead of failing

libvirt's logical pool cannot change a volume's capacity, so every
resize of such a disk ended in a 500. Disks are resized one at a time;
VIR_ERR_NO_SUPPORT becomes a message naming the disk, and the other
disks still grow.

A live test creates an LVM pool from the storage page on a spare disk
(TEST_LIBVIRT_LVM_DEVICE; the Vagrant computes get /dev/vdb), attaches
new and existing volumes to stopped and running VMs as block disks, and
checks the refused resize in every state.
This commit is contained in:
catborise 2026-10-18 12:15:28 +03:00
parent a83b46d65d
commit c46212bb38
5 changed files with 198 additions and 13 deletions

View file

@ -35,6 +35,7 @@ from libvirt import (VIR_DOMAIN_UNDEFINE_KEEP_NVRAM,
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE,
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA,
VIR_DOMAIN_UNDEFINE_NVRAM,
VIR_ERR_NO_SUPPORT,
libvirtError)
from logs.views import addlogmsg
from operations import claims, jobs
@ -960,13 +961,20 @@ def resize_disk(request, pk):
})
messages.error(request, msg)
else:
instance.proxy.resize_disk(disks_new)
devs_str = ", ".join([d["dev"] for d in disks_new])
msg = _("Disk is resized: %(dev)s") % {"dev": devs_str}
addlogmsg(
request.user.username, instance.compute.name, instance.name, msg
)
messages.success(request, msg)
for disk in disks_new:
try:
instance.proxy.resize_disk([disk])
except libvirtError as err:
# an LVM pool, for one, cannot resize its volumes
if err.get_error_code() != VIR_ERR_NO_SUPPORT:
raise
messages.error(request, _("The storage pool of %(dev)s cannot resize its volumes") % {"dev": disk["dev"]})
continue
msg = _("Disk is resized: %(dev)s") % {"dev": disk["dev"]}
addlogmsg(
request.user.username, instance.compute.name, instance.name, msg
)
messages.success(request, msg)
return redirect(reverse("instances:instance", args=[instance.id]) + "#resize")