mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix: a volume a job writes is not copied, attached or its pool stopped; download progress each second
A download into a pool listed its volume while it was written. The page let a superuser copy it (the copy got a half-written file, live), attach it to a VM, or stop the pool under it. Now: - the copy job claims its source volume shared, and the worker refuses a copy whose name the source's format changed before the claim; - attaching an existing volume holds it exclusive from its first read, so neither a download nor a copy is under way, and its format is read after the download ended; - stopping or deleting a pool (page and API) holds the pool exclusive, and its backup target's claim if it is one; restores claim the pools they write into shared. Each is refused with the job in the way named, as a volume delete already was. The download recorded its progress every 16 MiB, so a slow server's bar stayed empty for a long time; it records it each second, with the cancel check. The worker checks the name is still free before it starts. A snapshot name or tag typed in the VM list's bulk form keeps the list from reloading, as a chosen VM did.
This commit is contained in:
parent
7c8f5b3150
commit
7e70595fd2
19 changed files with 588 additions and 450 deletions
|
|
@ -10,10 +10,11 @@ from django.utils.translation import gettext as _
|
|||
from drf_spectacular.utils import extend_schema, inline_serializer
|
||||
from libvirt import libvirtError
|
||||
from logs.audit import audit, failed
|
||||
from operations import claims
|
||||
from rest_framework import serializers, status, viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from vmbackups.utils import refuse_backup_volume
|
||||
from vmbackups.utils import pool_stop_claims, refuse_backup_volume
|
||||
from vrtManager.storage import wvmStorage, wvmStorages
|
||||
from webvirtcloud.serializers import ErrorSerializer, StatusSerializer
|
||||
|
||||
|
|
@ -93,7 +94,9 @@ class StorageViewSet(viewsets.ViewSet):
|
|||
conn = wvmStorage(
|
||||
compute.hostname, compute.login, compute.password, compute.type, pk
|
||||
)
|
||||
with audit(request, compute, f"Storage pool {pk}", "stop"):
|
||||
# not while a job (a download, a copy) works in it
|
||||
with claims.hold(pool_stop_claims(compute, pk)), \
|
||||
audit(request, compute, f"Storage pool {pk}", "stop"):
|
||||
ret = conn.stop()
|
||||
return Response({"status": "Pool stop command send: " + str(ret)})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue