mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): a clone stays on the host of the VM it was made from
With "VM Clone Auto Migrate" on, a new clone was migrated to a random compute, whatever storage, CPU or network that host had, and a failed migration showed as a failed clone although the clone existed. The setting and its code are removed; migration appsettings.0015 deletes the setting. A clone can be migrated afterwards like any VM. The README's update notes list the migration changes: the migration address, storage pools for the disk check, and this setting.
This commit is contained in:
parent
5c22fc8436
commit
1016f745c2
5 changed files with 51 additions and 7 deletions
|
|
@ -107,6 +107,19 @@ class ClonePermissionTestCase(TestCase):
|
|||
self.assertEqual(res.status_code, 403)
|
||||
proxy.clone_instance.assert_not_called()
|
||||
|
||||
def test_a_clone_stays_on_the_host_of_its_vm(self):
|
||||
# the removed "VM Clone Auto Migrate" setting sent it to a random host
|
||||
other = Compute.objects.create(name="other-host", hostname="198.51.100.20", login="", password="", type=4)
|
||||
with self.mocked_libvirt() as proxy, \
|
||||
patch("instances.views.utils.migrate_instance") as migrate, \
|
||||
patch.object(app_settings, "CLONE_INSTANCE_AUTO_MIGRATE", "True", create=True), \
|
||||
patch("instances.views.Compute.objects.order_by") as random_host:
|
||||
random_host.return_value.first.return_value = other
|
||||
self._clone(self.owner_change, self._valid_post())
|
||||
proxy.clone_instance.assert_called_once()
|
||||
migrate.assert_not_called()
|
||||
self.assertEqual(Instance.objects.get(name="clone-vm").compute, self.instance.compute)
|
||||
|
||||
def test_viewer_can_clone_a_template(self):
|
||||
self.instance.is_template = True
|
||||
self.instance.save(update_fields=["is_template"])
|
||||
|
|
|
|||
|
|
@ -1854,13 +1854,6 @@ def clone(request, pk):
|
|||
request.user.username, instance.compute.name, new_instance.name, msg
|
||||
)
|
||||
|
||||
if app_settings.CLONE_INSTANCE_AUTO_MIGRATE == "True":
|
||||
new_compute = Compute.objects.order_by("?").first()
|
||||
if new_compute != instance.compute:
|
||||
utils.migrate_instance(
|
||||
new_compute, new_instance, request.user, offline=True
|
||||
)
|
||||
|
||||
return redirect(reverse("instances:instance", args=[new_instance.id]))
|
||||
except (libvirtError, ValueError, OSError) as e: # OSError includes a lock timeout
|
||||
messages.error(request, error_text(request, e))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue