mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): a late cancel leaves a later job's migration or disk move alone
A cancel that comes before libvirt began a migration or disk move waits for it. When the job ended meanwhile and another job of the VM started its own migration or copy within the hook's second of sleep, the hook took that for its own and aborted it. The hook now asks whether its job is still active right before it aborts.
This commit is contained in:
parent
f6c7c54fba
commit
bf08b6cfa5
2 changed files with 30 additions and 11 deletions
|
|
@ -308,6 +308,21 @@ class MigrateJobTestCase(TransactionTestCase):
|
|||
get_kind(op.kind).cancel(op)
|
||||
proxy.return_value.instance.abortJob.assert_not_called()
|
||||
|
||||
def test_a_waiting_cancel_leaves_the_migration_of_a_later_job_alone(self):
|
||||
# the job ends before libvirt began; another job's migration of the VM starts meanwhile
|
||||
op = self.queue(live_migrate="true")
|
||||
self.start(op)
|
||||
|
||||
def ended(_seconds):
|
||||
Operation.objects.filter(pk=op.pk).update(state=Operation.FAILED)
|
||||
|
||||
with patch("instances.jobs.wvmInstance") as proxy, patch("instances.jobs.time.sleep", side_effect=ended):
|
||||
dom = proxy.return_value.instance
|
||||
dom.isActive.return_value = True
|
||||
dom.jobInfo.side_effect = [[0] * 12] + [[2] + [0] * 11] * 3 # no job yet, then the later one's
|
||||
get_kind(op.kind).cancel(op)
|
||||
dom.abortJob.assert_not_called()
|
||||
|
||||
def test_each_end_of_a_migration_leaves_one_logs_row(self):
|
||||
op = self.queue(live_migrate="true")
|
||||
ctx = self.start(op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue