1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(jobs): a live clone that recovery cannot define ends uncertain

After a successful copy, recovery defined the clone; a define that
failed raised, and recovery retried it with the same result. One case
is certain: a worker killed after define_clone copied the UEFI
variables but before it defined the VM leaves <clone>_VARS.fd, and every
retry is refused because the volume exists. The job then waited for
recovery with its claims on the source VM and the clone's name. A
libvirt error now ends it uncertain, naming the error and the copied
volumes; an unreachable host still waits.
This commit is contained in:
catborise 2026-11-06 08:58:33 +03:00
parent 2afb7be196
commit 42745c4647
6 changed files with 98 additions and 64 deletions

View file

@ -19,7 +19,7 @@ from instances.jobs import CloneInstance
from instances.models import Instance
from operations.utils import words
from operations.jobs import Cancelled, Context
from vrtManager.util import OperationError
from vrtManager.util import ConnectionFailed, OperationError
from operations.models import Claim, Operation, acquire
@ -601,6 +601,17 @@ class LiveCloneJobTestCase(TransactionTestCase):
Instance.objects.filter(uuid=op.intent["uuid"]).delete()
op.delete()
def test_recovery_that_cannot_define_the_clone_ends_uncertain(self):
# the worker stopped after define_clone copied the UEFI variables: a retry finds the copy there
self.track("define_clone", libvirt_error(libvirt.VIR_ERR_STORAGE_VOL_EXIST))
outcome, _op = self.recovered(copy_result=[True, ""])
self.assertEqual(outcome.state, Operation.UNCERTAIN)
self.assertIn("/real/copy-vda.qcow2", words(outcome.error))
self.assertEqual(self.deleted(), [])
self.track("define_clone", ConnectionFailed("host down"))
with self.assertRaises(ConnectionFailed):
self.recovered(copy_result=[True, ""])
def test_recovery_gives_the_clone_the_size_asked_and_starts_it(self):
clone = {"name": "copy", "disk-vda": "copy-vda.qcow2", "disk_owner_uid": 107, "disk_owner_gid": 107,
"vcpu": 2, "memory": None, "start": True}