mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): a VM's destruction checks its files on every host first
Destroying a VM with its disk files forced it off first and then worked out which files to delete, so a check that failed left the VM stopped, and only this host's VMs and volumes were checked: a file on shared storage that a VM on another host uses was deleted. The files are now worked out before the VM is stopped: the disks it runs with and those of its next start, as before with their snapshot files and seed. A file a VM or volume of another of the panel's hosts uses at the same path (shared storage is mounted at one path on every host, as migration needs) is kept like one used here; another record of the VM's own host is skipped, as there the VM itself uses them. A host that cannot be read stops the destruction with its name, before anything is stopped or deleted.
This commit is contained in:
parent
79b257ab80
commit
e2b9598074
8 changed files with 125 additions and 12 deletions
|
|
@ -88,7 +88,7 @@ class DeleteWithDisksTestCase(unittest.TestCase):
|
|||
vm.wvm = MagicMock()
|
||||
vm.refresh_instance_pools = MagicMock()
|
||||
vm.get_uuid = lambda: UUID
|
||||
vm.get_disk_devices = lambda: [{"path": "/pool/web-1.qcow2"}]
|
||||
vm.get_disk_devices = lambda config=False: [{"path": "/pool/web-1.qcow2"}]
|
||||
vm._snapshot_chain_files = lambda own: []
|
||||
vm.paths_used_by_other_domains = lambda own: set()
|
||||
vm.backing_path = lambda path: None
|
||||
|
|
@ -112,6 +112,13 @@ class DeleteWithDisksTestCase(unittest.TestCase):
|
|||
vm, _ = self.vm(seed_in_pool=False)
|
||||
self.assertEqual(vm.split_disk_paths_by_use(), (["/pool/web-1.qcow2"], []))
|
||||
|
||||
def test_its_next_start_disks_and_the_files_other_hosts_use(self):
|
||||
vm, _ = self.vm(seed_in_pool=False)
|
||||
vm.get_disk_devices = lambda config=False: [{"path": "/pool/web-1.qcow2"}] + (
|
||||
[{"path": "/nfs/pending.qcow2"}] if config else [])
|
||||
self.assertEqual(vm.split_disk_paths_by_use(lambda own: {"/nfs/pending.qcow2"} & set(own)),
|
||||
(["/pool/web-1.qcow2"], ["/nfs/pending.qcow2"]))
|
||||
|
||||
|
||||
class CloneTestCase(unittest.TestCase):
|
||||
def test_a_clone_does_not_take_the_vms_seed(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue