mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
fix(instances): a clone's recovery tells how to thaw a guest paused meanwhile
A live clone freezes the guest's file systems through its agent. When the worker stopped before the thaw and the VM was paused before the job was recovered, recovery skipped the thaw without a word: resumed, the guest stayed frozen. libvirt thaws no paused guest, so the job's warning now says to resume the VM, then thaw it with virsh domfsthaw.
This commit is contained in:
parent
272a40f4e1
commit
2c7d7e9c3b
6 changed files with 384 additions and 353 deletions
|
|
@ -572,6 +572,8 @@ def _delete_created(proxy, op):
|
|||
|
||||
CLONE_STATE_REFUSED = _("The VM must be running, paused or shut off to be cloned")
|
||||
THAW_FAILED = _("The guest's file systems could not be thawed (%(error)s); thaw them with: virsh domfsthaw %(vm)s")
|
||||
PAUSED_FROZEN = _("%(vm)s is paused and its file systems may still be frozen: resume it, then thaw them with: "
|
||||
"virsh domfsthaw %(vm)s")
|
||||
|
||||
|
||||
def _check_clone_state(proxy, data):
|
||||
|
|
@ -736,12 +738,15 @@ class CloneInstance(Kind):
|
|||
return Outcome(Operation.UNCERTAIN, error=say(_(
|
||||
"The VM is no longer on the compute the job ran on; check these volumes, then resolve this job: "
|
||||
"%(volumes)s"), volumes=created))
|
||||
thawed = []
|
||||
if op.intent.get("frozen") and proxy.get_status() == 1:
|
||||
thawed, vm = [], op.resource_label.rpartition("/")[2]
|
||||
status = proxy.get_status()
|
||||
if op.intent.get("frozen") and status == 1:
|
||||
try:
|
||||
proxy.fs_thaw()
|
||||
except libvirtError as err:
|
||||
thawed = say(THAW_FAILED, error=err, vm=op.resource_label.rpartition("/")[2])
|
||||
thawed = say(THAW_FAILED, error=err, vm=vm)
|
||||
elif op.intent.get("frozen") and status == 3: # libvirt thaws no paused guest
|
||||
thawed = say(PAUSED_FROZEN, vm=vm)
|
||||
outcome = self._live_outcome(proxy, op)
|
||||
if thawed and outcome.state == Operation.SUCCEEDED: # a warning of the clone, as when the job made it
|
||||
outcome.result["warning"] = [*outcome.result.get("warning", []), *thawed]
|
||||
|
|
|
|||
|
|
@ -744,3 +744,13 @@ class LiveCloneJobTestCase(TransactionTestCase):
|
|||
self.proxy.get_status.return_value = 5
|
||||
self.recovered(frozen=True)
|
||||
self.assertNotIn("fs_thaw", self.events)
|
||||
|
||||
def test_recovery_tells_how_to_thaw_a_guest_paused_meanwhile(self):
|
||||
# libvirt thaws no paused guest: resumed, it would stay frozen without a word
|
||||
self.proxy.get_status.return_value = 3
|
||||
self.proxy.backup_result.return_value = None
|
||||
self.proxy.backup_targets.return_value = {"/other/x.qcow2"}
|
||||
outcome, _op = self.recovered(defined=True, frozen=True)
|
||||
self.assertEqual(outcome.state, Operation.SUCCEEDED)
|
||||
self.assertIn("resume it, then thaw them with: virsh domfsthaw", words(outcome.result["warning"]))
|
||||
self.proxy.fs_thaw.assert_not_called()
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue