mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(instances): a shut-off clone into a volume name its pool has is refused before it begins
libvirt refused the copy only after the job had begun; recovery then found a volume of the planned name and ended the job uncertain, holding the VM. The names are checked when the job is queued and before it runs, as a live clone did; that check now refreshes the pool first, so a live clone's free space is read current too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
018ca69a3b
commit
4ee88d6767
4 changed files with 52 additions and 10 deletions
|
|
@ -536,12 +536,15 @@ THAW_FAILED = _("The guest's file systems could not be thawed (%(error)s); thaw
|
|||
|
||||
|
||||
def _check_clone_state(proxy, data):
|
||||
"""A shut-off VM is copied as it is; a running or paused one only when a
|
||||
live clone can work; other states are refused."""
|
||||
"""A shut-off VM is copied as it is, into names its pools do not have; a
|
||||
running or paused one only when a live clone can work; other states are
|
||||
refused."""
|
||||
status = proxy.get_status()
|
||||
if status in (1, 3):
|
||||
proxy.live_clone_targets(data, **_snapshot_free_space())
|
||||
elif status != 5:
|
||||
elif status == 5:
|
||||
proxy.check_clone_volumes(data)
|
||||
else:
|
||||
raise util.OperationError(CLONE_STATE_REFUSED)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -301,6 +301,15 @@ class LiveCloneJobTestCase(TransactionTestCase):
|
|||
self.proxy.live_clone_targets.assert_not_called()
|
||||
self.assertFalse(Operation.objects.get(pk=op.pk).intent["live"])
|
||||
|
||||
def test_a_shut_off_copy_into_a_volume_name_in_use_is_refused_before_it_begins(self):
|
||||
"""libvirt would refuse it after the job began: the job would end uncertain."""
|
||||
self.proxy.get_status.return_value = 5
|
||||
op = self.op()
|
||||
self.proxy.check_clone_volumes.side_effect = OperationError("Volume copy.qcow2 already exists in storage pool default")
|
||||
with self.assertRaisesMessage(OperationError, "Volume copy.qcow2 already exists"):
|
||||
CloneInstance().precheck(op, None)
|
||||
self.proxy.check_clone_volumes.assert_called_once_with(op.intent["clone"])
|
||||
|
||||
def test_a_name_taken_since_the_job_was_queued_stops_it(self):
|
||||
op = self.op()
|
||||
other = Compute.objects.create(name="live-d", hostname="192.0.2.33", login="root", password="", type=1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue