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:
parent
2afb7be196
commit
42745c4647
6 changed files with 98 additions and 64 deletions
|
|
@ -714,7 +714,14 @@ class CloneInstance(Kind):
|
|||
if not success:
|
||||
_delete_created(proxy, op)
|
||||
return Outcome(ended, error=say(errmsg or _("The copy failed")))
|
||||
proxy.define_clone(op.intent["clone"], op.intent["uuid"], {c["dev"]: c["path"] for c in created})
|
||||
try:
|
||||
proxy.define_clone(op.intent["clone"], op.intent["uuid"], {c["dev"]: c["path"] for c in created})
|
||||
except util.ConnectionFailed:
|
||||
raise # unreachable: recovery waits and retries
|
||||
except libvirtError as err: # it would fail the same way at every retry
|
||||
return Outcome(Operation.UNCERTAIN, error=say(_(
|
||||
"The disks were copied, but the clone could not be defined: %(error)s; check these volumes, "
|
||||
"then resolve this job: %(volumes)s"), error=err, volumes=volumes))
|
||||
return Outcome(Operation.SUCCEEDED, result=_clone_made(op, _finish_clone(op, op.intent["clone"], [])))
|
||||
|
||||
def log_entry(self, op, state):
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue