mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(vmbackups): fifth audit: offline copies, domain file mode, target check
- An offline backup is not published when the VM was started while its disks were copied (its NVRAM and TPM state would be newer than the disks); recovery does not publish it either. - A cancel asked during the last disk of an offline copy is honoured: the copies are removed instead of the backup being published. - The backup's domain definition is written 0600, as the TPM state is: it holds the graphics passwords. - The daily target check does not mark missing a backup finished in the last 10 minutes: written through another compute, its files may not be listed yet by this one's NFS client.
This commit is contained in:
parent
57d4b61c6e
commit
132676a772
7 changed files with 366 additions and 310 deletions
|
|
@ -144,6 +144,7 @@ class CreateBackupTests(TransactionTestCase):
|
|||
prefix = f"wvc-{op.intent['backup']}"
|
||||
self.assertEqual(self.written, [f"{prefix}-tpm-tpm2-00.permall", f"{prefix}-domain.xml", f"{prefix}-manifest.json"])
|
||||
self.assertEqual(self.modes[f"{prefix}-tpm-tpm2-00.permall"], "0600") # a secret
|
||||
self.assertEqual(self.modes[f"{prefix}-domain.xml"], "0600") # its graphics passwords
|
||||
tpm = self.backup(op).files.get(role=BackupFile.TPM)
|
||||
self.assertEqual((tpm.dev, tpm.volume, tpm.size, tpm.sha256), ("tpm2-00.permall", f"{prefix}-tpm-tpm2-00.permall", 5, "sha"))
|
||||
self.assertEqual(self.backup(op).manifest["tpm"], "copied")
|
||||
|
|
@ -424,6 +425,27 @@ class CreateBackupTests(TransactionTestCase):
|
|||
self.proxy.copy_disk_offline.assert_not_called()
|
||||
self.assertEqual(self.backup(op).state, Backup.FAILED)
|
||||
|
||||
def test_an_offline_copy_cancelled_during_its_last_disk_is_not_kept(self):
|
||||
op = self.submit()
|
||||
self.proxy.copy_disk_offline.side_effect = lambda *a: Operation.objects.filter(pk=op.pk).update(cancel_requested=True)
|
||||
with self.assertRaises(Cancelled):
|
||||
self.run_job(op)
|
||||
self.assertEqual(self.written, [])
|
||||
self.assertIn(f"wvc-{op.intent['backup']}-vda.qcow2", self.removed)
|
||||
self.assertEqual(self.backup(op).state, Backup.FAILED)
|
||||
|
||||
def test_a_vm_started_during_its_offline_copy_is_not_published(self):
|
||||
# its NVRAM and TPM state would be newer than the disks copied
|
||||
started = lambda *a: setattr(self.proxy.get_status, "return_value", libvirt.VIR_DOMAIN_RUNNING) # noqa: E731
|
||||
self.proxy.copy_disk_offline.side_effect = started
|
||||
op = self.interrupted(self.submit())
|
||||
self.assertEqual(self.written, [])
|
||||
outcome = CreateBackup().reconcile(op) # recovery does not publish it either
|
||||
self.assertEqual(outcome.state, Operation.FAILED)
|
||||
self.assertIn("started", str(outcome.error))
|
||||
self.assertIn(f"wvc-{op.intent['backup']}-vda.qcow2", self.removed)
|
||||
self.assertEqual(self.backup(op).state, Backup.FAILED)
|
||||
|
||||
def test_progress_counts_the_copied_disks(self):
|
||||
op = self.submit()
|
||||
self.run_job(op)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue