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

fix(storages): pool pages work while a volume is cloned, failed pools are undefined

- libvirt refuses to refresh a pool while a volume is cloned in it. The pool
  page, the volume list of the VM and create pages, upload planning and the
  API no longer fail on that refusal; they use the list libvirt has.
- A new pool that does not start (unreachable NFS server, a device LVM
  cannot use) is undefined again, so the name is free for another try.
- A pool reporting no size, such as an iSCSI pool without LUNs, shows its
  page instead of a division error.
- Each clone dialog shows its own format and metadata rows, so a format
  is never shown without Convert ticked and silently ignored.
- The new-volume size is labelled in GiB and is at least 1; an inactive
  pool shows no "None" volume count.
This commit is contained in:
catborise 2026-10-26 14:18:33 +03:00
parent 9e02286926
commit 63aba5d9c9
9 changed files with 89 additions and 44 deletions

View file

@ -1,9 +1,12 @@
import contextlib
from admin.permissions import IsSuperUser
from appsettings.settings import app_settings
from computes.models import Compute
from computes.utils import libvirt_compute_lock
from django.shortcuts import get_object_or_404
from drf_spectacular.utils import extend_schema, inline_serializer
from libvirt import libvirtError
from logs.audit import audit, failed
from rest_framework import serializers, status, viewsets
from rest_framework.decorators import action
@ -136,7 +139,6 @@ class VolumeViewSet(viewsets.ViewSet):
state = conn.is_active()
if state:
conn.refresh()
volume_queryset = conn.update_volumes()
else:
volume_queryset = None
@ -176,7 +178,8 @@ class VolumeViewSet(viewsets.ViewSet):
subject, action = f"Storage pool {storage_pk}", f"add volume {serializer.validated_data['name']}"
state = conn.is_active()
if state:
conn.refresh()
with contextlib.suppress(libvirtError): # refused while a volume is cloned in the pool
conn.refresh()
with audit(request, compute, subject, action) as entry:
ret = conn.create_volume(
serializer.validated_data["name"],