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
|
|
@ -391,6 +391,7 @@ class Scheduler:
|
|||
self.errors = {}
|
||||
self.stalled_since = {}
|
||||
self.failing_since = {}
|
||||
self.cancel_sent = set()
|
||||
self.inflight = set()
|
||||
|
||||
def schedule_orphans(self):
|
||||
|
|
@ -415,6 +416,7 @@ class Scheduler:
|
|||
def _done(self, op_id):
|
||||
for table in (self.next_try, self.attempts, self.errors, self.stalled_since, self.failing_since):
|
||||
table.pop(op_id, None)
|
||||
self.cancel_sent.discard(op_id)
|
||||
|
||||
def _take_over(self, op):
|
||||
"""True if op is now this worker's. Another host's job ends uncertain
|
||||
|
|
@ -479,6 +481,10 @@ class Scheduler:
|
|||
return
|
||||
self.failing_since.pop(op_id, None)
|
||||
if outcome.state == Operation.RUNNING:
|
||||
# libvirt still runs it: a cancel asked meanwhile goes to libvirt once, as for a job thread's
|
||||
if op.cancel_requested and op_id not in self.cancel_sent:
|
||||
self.cancel_sent.add(op_id)
|
||||
_guarded(jobs.get_kind(op.kind).cancel, op)
|
||||
now = time.monotonic()
|
||||
if not outcome.stalled:
|
||||
self.stalled_since.pop(op_id, None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue