nova/nova/tests/unit/virt
Matt Riedemann a16fa14ce4 libvirt: check image type before removing snapshots in _cleanup_resize
Change Ic683f83e428106df64be42287e2c5f3b40e73da4 added some disk
cleanup logic to _cleanup_resize because some image backends (Qcow2,
Flat and Ploop) will re-create the instance directory and disk.info
file when initializing the image backend object.

However, that change did not take into account volume-backed instances
being resized will not have a root disk *and* if the local disk is
shared storage, removing the instance directory effectively deletes
the instance files, like the console.log, on the destination host
as well. Change I29fac80d08baf64bf69e54cf673e55123174de2a was made
to resolve that issue.

However (see the pattern?), if you're doing a resize of a
volume-backed instance that is not on shared storage, we won't remove
the instance directory from the source host in _cleanup_resize. If the
admin then later tries to live migrate the instance back to that host,
it will fail with DestinationDiskExists in the pre_live_migration()
method.

This change is essentially a revert of
I29fac80d08baf64bf69e54cf673e55123174de2a and alternate fix for
Ic683f83e428106df64be42287e2c5f3b40e73da4. Since the root problem
is that creating certain imagebackend objects will recreate the
instance directory and disk.info on the source host, we simply need
to avoid creating the imagebackend object. The only reason we are
getting an imagebackend object in _cleanup_resize is to remove
image snapshot clones, which is only implemented by the Rbd image
backend. Therefore, we can check to see if the image type supports
clones and if not, don't go through the imagebackend init routine
that, for some, will recreate the disk.

Change-Id: Ib10081150e125961cba19cfa821bddfac4614408
Closes-Bug: #1769131
Related-Bug: #1666831
Related-Bug: #1728603
(cherry picked from commit 8e3385707c)
(cherry picked from commit 174764340d)
(cherry picked from commit c72a0a7665)
2018-05-10 12:08:39 -04:00
..
disk Merge "Guestfs handle no passwd or group in image" 2016-12-12 06:27:16 +00:00
hyperv hyperv: Fixes Generation 2 VMs volume boot order 2017-08-11 17:13:16 +00:00
image Use assert(Not)Equal instead of assertTrue(A == X) 2016-06-03 16:53:15 +01:00
ironic Handle ironicclient failures in Ironic driver 2017-08-08 11:14:53 -04:00
libvirt libvirt: check image type before removing snapshots in _cleanup_resize 2018-05-10 12:08:39 -04:00
vmwareapi Port virt vmwareapi tests to Python 3 2016-12-13 15:32:04 +08:00
xenapi Merge "XenAPI: Create linux bridge in dest host during live migration" into stable/ocata 2017-08-11 18:24:12 +00:00
__init__.py
fakelibosinfo.py Fix misuse of assertTrue in console and virt tests 2016-02-22 16:09:21 +09:00
test_block_device.py libvirt: Block swap volume attempts with encrypted volumes prior to Queens 2018-04-18 19:57:30 +00:00
test_configdrive.py force_config_drive: StrOpt -> BoolOpt 2015-11-11 19:59:22 +00:00
test_diagnostics.py
test_driver.py Move driver_dict_from_config to libvirt driver 2016-11-09 11:48:20 -05:00
test_events.py
test_fake.py
test_firewall.py Use more specific asserts in tests 2016-10-12 11:12:08 +01:00
test_hardware.py Mark sibling CPUs as 'used' for cpu_thread_policy = 'isolated' 2016-12-13 11:23:07 +04:00
test_imagecache.py Remove mox from tests/unit/virt/test_imagecache.py 2016-06-16 23:40:01 +00:00
test_images.py Bump prlimit cpu time for qemu from 2 to 8 2016-12-08 10:41:31 -05:00
test_netutils.py libvirt: expose virtual interfaces with vlans to metadata 2017-01-26 17:06:56 -05:00
test_osinfo.py Do not attempt to load osinfo if we do not have os_distro 2017-03-30 05:11:40 +00:00
test_virt.py Remove mox from nova/tests/unit/virt/test_virt.py 2016-11-28 08:49:51 +00:00
test_virt_drivers.py libvirt: Block swap volume attempts with encrypted volumes prior to Queens 2018-04-18 19:57:30 +00:00
test_volumeutils.py Switch to using os-brick 2015-07-27 10:47:22 -07:00