mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(storages): a volume another compute's VM uses on shared storage is not deleted
A pool on shared storage (an NFS share, or a directory mounted from one) holds the same file at the same path on every host that mounts it. A VM's delete checks the panel's other computes before it deletes its disk files, but the pool page, its API and a VM's disk delete checked only their own host: a disk of a VM on another compute could be deleted. They now ask the other computes too, and refuse while one uses the file or cannot be reached. The other computes are asked before this host's lock is taken, and before a VM's disk is detached.
This commit is contained in:
parent
fb3b2f479e
commit
143a74b145
11 changed files with 277 additions and 196 deletions
|
|
@ -1578,6 +1578,12 @@ def delete_vol(request, pk):
|
|||
_("Volume %(vol)s is used by another VM; detach it instead") % {"vol": disk["image"]},
|
||||
)
|
||||
return _back(request, pk, "disks")
|
||||
try: # before the disk is detached
|
||||
conn_delete.check_unused_elsewhere(
|
||||
disk["image"], lambda paths: utils.paths_used_on_other_computes(instance.compute, paths))
|
||||
except util.OperationError as err:
|
||||
messages.error(request, str(err))
|
||||
return _back(request, pk, "disks")
|
||||
|
||||
volume = f"{disk['storage']}/{disk['image']}"
|
||||
with audit_vm(request, instance, f"detach disk {dev}"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue