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

fix(jobs): a cancel reaches libvirt for a job that recovery watches

The worker sends cancels only to jobs its own threads run. After a
worker restart, a migration or live clone that libvirt still ran was
watched by recovery; a cancel then moved the job to cancelling, the page
said so, but nothing told libvirt, and the job ran to its end. Recovery
now sends the cancel once while libvirt still runs the job, and a
migration it aborted ends cancelled rather than failed.
This commit is contained in:
catborise 2026-11-06 09:02:12 +03:00
parent 37f97f4e79
commit 30f5bf6535
4 changed files with 28 additions and 0 deletions

View file

@ -1076,6 +1076,8 @@ class MigrateInstance(Kind):
return Outcome(Operation.SUCCEEDED, result=_moved(op, dest))
if source is not None and dest is None:
_shut_off_again(op, source)
if op.cancel_requested:
return Outcome(Operation.CANCELLED)
return Outcome(Operation.FAILED, error=say(_("The VM stayed on the source host")))
return Outcome(Operation.UNCERTAIN, error=say(_(
"The VM is on both computes or on neither; check them, then resolve this job.")))

View file

@ -70,6 +70,10 @@ class MigrateJobTestCase(TransactionTestCase):
dom.isActive.return_value = False
with patch("instances.jobs._domain", side_effect=[dom, None]): # source, destination
self.assertEqual(MigrateInstance().reconcile(op).state, Operation.FAILED)
op.cancel_requested = True # recovery sent the cancel: libvirt aborted it
with patch("instances.jobs._domain", side_effect=[dom, None]):
self.assertEqual(MigrateInstance().reconcile(op).state, Operation.CANCELLED)
op.cancel_requested = False
dom.isActive.return_value = True
dom.jobInfo.return_value = [2] + [0] * 11 # VIR_DOMAIN_JOB_UNBOUNDED
with patch("instances.jobs._domain", side_effect=[dom, dom]):