mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix: a downloading volume is not put in a new VM or a CD-ROM; slow downloads read as bytes come
A download writes its volume under its final name, so the volume was offered while half written. #685 kept a copy and an attach away from it; a new VM and a CD-ROM still took it. The VM create job now claims the volumes it is made from (a writable one exclusive, a template or a CD-ROM image shared), and adding a CD-ROM or inserting media holds the ISO's volume shared and reads the ISO again in that pool under the claim (iso_location, iso_path_in). Each is refused with the download named. A claim's key holds a pool's and a volume's names: longer than 255 characters on PostgreSQL it failed the request; Claim.resource is text. A pool that belongs to more than one backup target is not stopped while a backup to any of them runs (it took the first target only). The download read 1 MiB at a time: on a slow server a cancel and the progress waited for a whole MiB. It reads what has come (read1).
This commit is contained in:
parent
1a39bd3480
commit
84d633af08
17 changed files with 484 additions and 378 deletions
|
|
@ -13,7 +13,8 @@ from instances.api.serializers import CreateInstanceSerializer
|
|||
from instances.models import Instance
|
||||
from instances.utils import nic_macs
|
||||
from operations.jobs import Context, Outcome, finish, get_kind
|
||||
from operations.models import Operation, acquire
|
||||
from operations.claims import admit
|
||||
from operations.models import Claim, Operation, acquire
|
||||
|
||||
|
||||
wvm_create = MagicMock() # the page and the job reach the same host
|
||||
|
|
@ -47,6 +48,25 @@ class CreateInstanceViewTests(TestCase):
|
|||
self.assertEqual(conn.create_instance.call_args.kwargs["volumes"][0]["bus"], "virtio")
|
||||
self.assertTrue(Instance.objects.filter(name="new-vm").exists())
|
||||
|
||||
@patch("instances.views.wvmCreate", new=wvm_create)
|
||||
@patch("instances.views.NewVMForm")
|
||||
def test_the_volumes_it_is_made_from_are_claimed(self, form_class):
|
||||
# not while a download writes them: an existing disk exclusive, a template shared
|
||||
self.create(form_class)
|
||||
compute = Compute.objects.get()
|
||||
self.assertIn((f"volume:{compute.pk}:pool-b/base.qcow2", Claim.EXCLUSIVE),
|
||||
set(Claim.objects.values_list("resource", "mode")))
|
||||
Operation.objects.all().delete()
|
||||
self.create(form_class, images="", template="base.qcow2", template_pool="pool-b", storage="default")
|
||||
self.assertIn((f"volume:{compute.pk}:pool-b/base.qcow2", Claim.SHARED),
|
||||
set(Claim.objects.values_list("resource", "mode")))
|
||||
Operation.objects.all().delete()
|
||||
admit({f"volume:{compute.pk}:pool-b/base.qcow2": Claim.EXCLUSIVE}, holder="other-node:1:1")
|
||||
response, _conn = self.create(form_class)
|
||||
self.assertIn("A short operation is in progress on this resource; try again in a moment.",
|
||||
[str(m) for m in get_messages(response.wsgi_request)])
|
||||
self.assertFalse(Operation.objects.exists())
|
||||
|
||||
@patch("instances.views.wvmCreate", new=wvm_create)
|
||||
@patch("instances.views.NewVMForm")
|
||||
def test_a_volume_is_taken_from_its_own_pool(self, form_class):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue