1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(migrate): recovery removes the disk copies of a migration whose worker stopped

A worker that stopped during the copy left the partial files on the
destination: libvirt ends the migration and the VM stays, but the files
took the space and refused the next try, as a copy never replaces a
file. The job records the copies before libvirt makes them, and
recovery deletes them while the destination has no VM of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-07 22:47:08 +03:00
parent d2a637cf33
commit aadf5270f2
5 changed files with 69 additions and 7 deletions

View file

@ -269,6 +269,14 @@ class DiskCopyTestCase(unittest.TestCase):
raise libvirt.libvirtError(message)
source.instance.migrate3.side_effect = migrate3
def test_the_copies_are_told_before_libvirt_makes_them(self):
"""A job records them: recovery removes them after a worker that stopped."""
source, pool = Source(1, domain(disk(f"{IMAGES}/vm.qcow2"))), Pool("fast", FAST)
told = []
source.instance.migrate3.side_effect = lambda *args: self.assertEqual(told, [[{"pool": "fast", "dest": f"{FAST}/vm.qcow2"}]])
migrate(destination(pool), source, {"vda": "fast"}, on_copy=told.append)
source.instance.migrate3.assert_called_once()
def test_a_failed_migration_removes_the_partial_copies(self):
source, pool = Source(1, domain(disk(f"{IMAGES}/vm.qcow2"))), Pool("fast", FAST)
self.fail_after_copying(source, pool, "operation aborted: canceled by client")