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

fix(instances): a create whose definition answer was lost keeps the VM's disk

A definition can go through on the host while its answer is lost, as when
the connection drops right then. The create job took every failed
definition for none and deleted the new disk and seed, so the VM could be
left defined without them, and recovery then reported it created.

The job now asks the host for the VM's UUID first. Only when the host says
there is no such VM do the new volumes go; otherwise they stay and recovery
decides, recording the VM it finds.

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-10 20:46:13 +03:00
parent b7c5f98ba5
commit 590b8d956d
4 changed files with 34 additions and 1 deletions

View file

@ -5,7 +5,7 @@ from appsettings.settings import get_settings
from computes.models import Compute
from django.contrib.auth import get_user_model
from django.test import TestCase
from libvirt import libvirtError
from libvirt import VIR_ERR_NO_DOMAIN, libvirtError
from instances.jobs import CreateInstance
from operations import jobs
@ -37,6 +37,9 @@ class CreateRollbackTestCase(TestCase):
conn.get_dom_capabilities.return_value = {"cpu_modes": ["host-model"]}
conn.get_instances.return_value = []
conn.create_volume.return_value = "/pool/rb-vm.qcow2"
missing = libvirtError("no domain")
missing.get_error_code = lambda: VIR_ERR_NO_DOMAIN
conn.wvm.lookupByUUIDString.side_effect = missing # until the job defines the VM
op = jobs.submit("instance.create", self.admin, {**PARAMS, "compute": self.compute.pk}, "key-rollback1")
acquire("wvc-test:1:a", "wvc-test")
Operation.objects.filter(pk=op.pk).update(state=Operation.RUNNING, worker="wvc-test:1:a")