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

fix(backups): a verification marks each damaged backup of the chain; an error told once

Verifying an incremental backup put what it found only on that backup: a
base whose file was changed or missing stayed unmarked, so restoring it
gave no warning and no badge showed it. Each backup of the chain is now
verified with it and holds the damage of its files and of those it builds
on. Verifications of backups of one chain run one at a time, so an older
read never writes over a newer finding; the rows and the job's own result
are written together, and recovery reads that result, also when a cancel
came after the reads.

A job whose recovery found the error it had raised stored it twice (the
verify job's damage, in its page and its alert).
This commit is contained in:
catborise 2026-11-19 18:55:17 +03:00
parent 2c8493ba8c
commit fc6ad4e8ca
5 changed files with 87 additions and 23 deletions

View file

@ -88,6 +88,11 @@ def backup_key(uuid):
return f"backup:{uuid}"
def verify_key(uuid):
"""A backup being verified: one verification at a time writes what it found on it."""
return f"verify:{uuid}"
@cache
def _node():
"""The installation's id (worker.host_identity): the same after a container

View file

@ -149,6 +149,13 @@ class RecoveryTestCase(TransactionTestCase):
self.run_due()
self.assertEqual(words(self.reload(op).error), "resource busy: X")
def test_a_finding_that_repeats_the_raised_error_is_stored_once(self):
op = self.orphan({}, worker=self.worker.identity)
self.scheduler.inspect_now(op.pk, error=say("damaged: X"))
with patch.object(fakes.ScriptedKind, "reconcile", return_value=Outcome(Operation.FAILED, error=say("damaged: X"))):
self.run_due()
self.assertEqual(words(self.reload(op).error), "damaged: X")
def test_progress_resets_the_stall_timer(self):
op = self.orphan({})
self.run_at(1000, Outcome(Operation.RUNNING, stalled=True))

View file

@ -478,8 +478,10 @@ class Scheduler:
self._done(op.pk)
def _error(self, op_id, finding):
"""What an unproven end stores: the error the job raised, then what libvirt shows."""
return [*self.errors.get(op_id, ()), *finding]
"""What an unproven end stores: the error the job raised, then what libvirt shows (a message the
raised error has already, once)."""
raised = list(self.errors.get(op_id, ()))
return [*raised, *(message for message in finding if message not in raised)]
def _phase(self, op_id, text, progress=None):
fields = {"phase": utils.safe_text(text)[:255]} if text else {}