Merge "Delete instance files from dest host in revert-resize"
This commit is contained in:
commit
199d208b7f
|
@ -812,7 +812,7 @@ class ComputeManager(manager.Manager):
|
|||
network_info,
|
||||
bdi, destroy_disks)
|
||||
|
||||
def _is_instance_storage_shared(self, context, instance):
|
||||
def _is_instance_storage_shared(self, context, instance, host=None):
|
||||
shared_storage = True
|
||||
data = None
|
||||
try:
|
||||
|
@ -821,7 +821,7 @@ class ComputeManager(manager.Manager):
|
|||
if data:
|
||||
shared_storage = (self.compute_rpcapi.
|
||||
check_instance_shared_storage(context,
|
||||
instance, data))
|
||||
instance, data, host=host))
|
||||
except NotImplementedError:
|
||||
LOG.warning(_LW('Hypervisor driver does not support '
|
||||
'instance shared storage check, '
|
||||
|
@ -3666,8 +3666,8 @@ class ComputeManager(manager.Manager):
|
|||
block_device_info = self._get_instance_block_device_info(
|
||||
context, instance, bdms=bdms)
|
||||
|
||||
destroy_disks = not self._is_instance_storage_shared(context,
|
||||
instance)
|
||||
destroy_disks = not self._is_instance_storage_shared(
|
||||
context, instance, host=migration.source_compute)
|
||||
self.driver.destroy(context, instance, network_info,
|
||||
block_device_info, destroy_disks)
|
||||
|
||||
|
|
|
@ -405,13 +405,13 @@ class ComputeAPI(object):
|
|||
instance=instance,
|
||||
dest_check_data=dest_check_data)
|
||||
|
||||
def check_instance_shared_storage(self, ctxt, instance, data):
|
||||
def check_instance_shared_storage(self, ctxt, instance, data, host=None):
|
||||
if self.client.can_send_version('3.29'):
|
||||
version = '3.29'
|
||||
else:
|
||||
version = '3.0'
|
||||
instance = jsonutils.to_primitive(instance)
|
||||
cctxt = self.client.prepare(server=_compute_host(None, instance),
|
||||
cctxt = self.client.prepare(server=_compute_host(host, instance),
|
||||
version=version)
|
||||
return cctxt.call(ctxt, 'check_instance_shared_storage',
|
||||
instance=instance,
|
||||
|
|
|
@ -4285,6 +4285,8 @@ class ComputeTestCase(BaseTestCase):
|
|||
self._stub_out_resize_network_methods()
|
||||
instance = self._create_fake_instance_obj()
|
||||
for operation in actions:
|
||||
if 'revert_resize' in operation:
|
||||
migration.source_compute = 'fake-mini'
|
||||
|
||||
def fake_migration_save(*args, **kwargs):
|
||||
raise test.TestingException()
|
||||
|
@ -6634,7 +6636,7 @@ class ComputeTestCase(BaseTestCase):
|
|||
evacuated_instance).AndReturn({'filename': 'tmpfilename'})
|
||||
self.compute.compute_rpcapi.check_instance_shared_storage(fake_context,
|
||||
evacuated_instance,
|
||||
{'filename': 'tmpfilename'}).AndReturn(False)
|
||||
{'filename': 'tmpfilename'}, host=None).AndReturn(False)
|
||||
self.compute.driver.check_instance_shared_storage_cleanup(fake_context,
|
||||
{'filename': 'tmpfilename'})
|
||||
self.compute.driver.destroy(fake_context, evacuated_instance,
|
||||
|
|
|
@ -3529,7 +3529,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
self.assertEqual([mock.call(), mock.call()],
|
||||
migration_obj_as_admin.mock_calls)
|
||||
|
||||
def test_revert_resize_instance_destroy_disks(self):
|
||||
def _test_revert_resize_instance_destroy_disks(self, is_shared=False):
|
||||
|
||||
# This test asserts that _is_instance_storage_shared() is called from
|
||||
# revert_resize() and the return value is passed to driver.destroy().
|
||||
|
@ -3561,20 +3561,27 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
|
||||
self.migration.source_compute = self.instance['host']
|
||||
|
||||
# inform compute that this instance uses shared storage
|
||||
_is_instance_storage_shared.return_value = True
|
||||
# Inform compute that instance uses non-shared or shared storage
|
||||
_is_instance_storage_shared.return_value = is_shared
|
||||
|
||||
self.compute.revert_resize(context=self.context,
|
||||
migration=self.migration,
|
||||
instance=self.instance,
|
||||
reservations=None)
|
||||
|
||||
_is_instance_storage_shared.assert_called_once_with(self.context,
|
||||
self.instance)
|
||||
_is_instance_storage_shared.assert_called_once_with(
|
||||
self.context, self.instance,
|
||||
host=self.migration.source_compute)
|
||||
|
||||
# since shared storage is used, we should not be instructed to
|
||||
# destroy disks here
|
||||
# If instance storage is shared, driver destroy method
|
||||
# should not destroy disks otherwise it should destroy disks.
|
||||
destroy.assert_called_once_with(self.context, self.instance,
|
||||
mock.ANY, mock.ANY, False)
|
||||
mock.ANY, mock.ANY, not is_shared)
|
||||
|
||||
do_test()
|
||||
|
||||
def test_revert_resize_instance_destroy_disks_shared_storage(self):
|
||||
self._test_revert_resize_instance_destroy_disks(is_shared=True)
|
||||
|
||||
def test_revert_resize_instance_destroy_disks_non_shared_storage(self):
|
||||
self._test_revert_resize_instance_destroy_disks(is_shared=False)
|
||||
|
|
Loading…
Reference in New Issue