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

fix(instances): a failed disk check on another host names it only to administrators

Deleting a VM with its disks checks every other compute for the files. A
compute that could not be read raised an OperationError whose text already
held that compute's name and libvirt's error, so owners who do not see
hosts got both. It is now a ConnectionFailed, which users who do not see
hosts get as "cannot be reached"; libvirt's text comes from the error
itself, so a connection that never opened no longer reads "None".
This commit is contained in:
catborise 2026-11-05 15:56:56 +03:00
parent 3fed1d04b4
commit 80b8d7fc91
2 changed files with 12 additions and 7 deletions

View file

@ -9,7 +9,8 @@ from django.urls import reverse
from instances.models import Instance
from instances.utils import paths_used_on_other_computes
from libvirt import VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, VIR_DOMAIN_UNDEFINE_NVRAM, libvirtError
from vrtManager.util import OperationError
from operations.utils import public_error_text
from vrtManager.util import ConnectionFailed, OperationError
class DestroyOrderTestCase(TestCase):
@ -243,5 +244,8 @@ class OtherComputesTestCase(TestCase):
hosts = self.hosts({"192.0.2.61": set(), "192.0.2.62": set()})
hosts["192.0.2.61"].paths_in_use.side_effect = libvirtError("connection refused")
with patch("instances.utils.wvmConnect", side_effect=lambda host, *args: hosts[host]):
with self.assertRaisesMessage(OperationError, "The disk files cannot be checked on host-b"):
with self.assertRaises(ConnectionFailed) as caught:
paths_used_on_other_computes(self.source, ["/nfs/a.qcow2"])
self.assertEqual(caught.exception.args[0], "The disk files cannot be checked on host-b: connection refused")
# users who do not see hosts get neither the host nor libvirt's text
self.assertEqual(public_error_text(caught.exception), "The host of this virtual machine cannot be reached right now.")