From e24f333cd5d3667a15c36ac502304bfb5a0e21df Mon Sep 17 00:00:00 2001 From: Daniel Genin Date: Mon, 28 Jul 2014 17:12:40 -0400 Subject: [PATCH] Raises NotImplementedError for LVM migration. Currently migration of an LVM backed instance results in a new instance being launched on the destination node, but the instance disk is neither copied to the destination nor deleted on the origin node. The problem is addressed by raising a NotImplementedError. Closes-Bug: #1270305 Closes-Bug: #1245595 Closes-Bug: #1241866 Change-Id: I8010230b1aa5ddc322d0c93dd916b7700c25ab81 DocImpact --- nova/compute/manager.py | 5 ++++ nova/tests/virt/libvirt/test_driver.py | 40 ++++++++++++++++++++++++++ nova/virt/libvirt/driver.py | 6 ++++ 3 files changed, 51 insertions(+) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 98f928111b45..c074bd35c7c0 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3463,6 +3463,11 @@ class ComputeManager(manager.Manager): instance_type, quotas, request_spec, filter_properties, node) + # NOTE(dgenin): This is thrown in LibvirtDriver when the + # instance to be migrated is backed by LVM. + # Remove when LVM migration is implemented. + except exception.MigrationPreCheckError: + raise except Exception: # try to re-schedule the resize elsewhere: exc_info = sys.exc_info() diff --git a/nova/tests/virt/libvirt/test_driver.py b/nova/tests/virt/libvirt/test_driver.py index bb2c5266d195..27544adc2889 100644 --- a/nova/tests/virt/libvirt/test_driver.py +++ b/nova/tests/virt/libvirt/test_driver.py @@ -9380,6 +9380,46 @@ class LibvirtDriverTestCase(test.TestCase): self.assertFalse(self.copy_or_move_swap_called) self.assertEqual(disk_info_text, out) + def test_migrate_disk_and_power_off_lvm(self): + """Test for nova.virt.libvirt.libvirt_driver.LibvirtConnection + .migrate_disk_and_power_off. + """ + + self.flags(images_type='lvm', group='libvirt') + disk_info = [{'type': 'raw', 'path': '/dev/vg/disk', + 'disk_size': '83886080'}, + {'type': 'raw', 'path': '/dev/disk.local', + 'disk_size': '83886080'}] + disk_info_text = jsonutils.dumps(disk_info) + + def fake_get_instance_disk_info(instance, xml=None, + block_device_info=None): + return disk_info_text + + def fake_destroy(instance): + pass + + def fake_get_host_ip_addr(): + return '10.0.0.1' + + def fake_execute(*args, **kwargs): + pass + + self.stubs.Set(self.libvirtconnection, 'get_instance_disk_info', + fake_get_instance_disk_info) + self.stubs.Set(self.libvirtconnection, '_destroy', fake_destroy) + self.stubs.Set(self.libvirtconnection, 'get_host_ip_addr', + fake_get_host_ip_addr) + self.stubs.Set(utils, 'execute', fake_execute) + + ins_ref = self._create_instance() + flavor = {'root_gb': 10, 'ephemeral_gb': 20} + + # Migration is not implemented for LVM backed instances + self.assertRaises(exception.MigrationPreCheckError, + self.libvirtconnection.migrate_disk_and_power_off, + None, ins_ref, '10.0.0.1', flavor, None) + def test_migrate_disk_and_power_off_resize_error(self): instance = self._create_instance() flavor = {'root_gb': 5} diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 6c39391ac291..5154213a5f9e 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -5096,6 +5096,12 @@ class LibvirtDriver(driver.ComputeDriver): block_device_info=block_device_info) disk_info = jsonutils.loads(disk_info_text) + # NOTE(dgenin): Migration is not implemented for LVM backed instances. + if (CONF.libvirt.images_type == 'lvm' and + not self._is_booted_from_volume(instance, disk_info_text)): + reason = "Migration is not supported for LVM backed instances" + raise exception.MigrationPreCheckError(reason) + # copy disks to destination # rename instance dir to +_resize at first for using # shared storage for instance dir (eg. NFS).