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:
parent
37f97f4e79
commit
30f5bf6535
4 changed files with 28 additions and 0 deletions
|
|
@ -184,6 +184,22 @@ class RecoveryTestCase(TransactionTestCase):
|
|||
self.run_at(1100, Outcome(Operation.RUNNING))
|
||||
self.assertNotIn(op.pk, self.scheduler.failing_since)
|
||||
|
||||
def test_a_cancel_of_a_job_libvirt_still_runs_goes_to_libvirt_once(self):
|
||||
op = self.orphan({})
|
||||
Operation.objects.filter(pk=op.pk).update(state=Operation.CANCELLING, cancel_requested=True)
|
||||
with patch.object(fakes.ScriptedKind, "cancel") as cancel:
|
||||
self.run_at(1000, Outcome(Operation.RUNNING))
|
||||
self.scheduler.next_try[op.pk] = 0
|
||||
self.run_at(1015, Outcome(Operation.RUNNING))
|
||||
cancel.assert_called_once()
|
||||
self.assertEqual(cancel.call_args.args[0].pk, op.pk)
|
||||
|
||||
def test_a_job_without_a_cancel_is_watched_without_one(self):
|
||||
self.orphan({})
|
||||
with patch.object(fakes.ScriptedKind, "cancel") as cancel:
|
||||
self.run_at(1000, Outcome(Operation.RUNNING))
|
||||
cancel.assert_not_called()
|
||||
|
||||
def test_a_job_that_never_recorded_its_intent_fails(self):
|
||||
op = self.orphan({}, effects=False)
|
||||
self.run_due()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue