From c2f57a126f135879b96947a6734db9b0e01c2ad3 Mon Sep 17 00:00:00 2001 From: zhengyao1 Date: Fri, 17 Jun 2016 17:42:00 +0800 Subject: [PATCH] live migration check source failed caused bdm.device_path lost Live migration vm, the process raised exception in the function "check_can_live_migrate_source". Then, the vm looks like running and active. But, the bdm.connection_info lost 'device_path' key. The reason is:the function check_can_live_migrate_source call the function _get_instance_block_device_info to check cinderclient, but this function will call cinder initialize_connection api interface and update BDM.connection_info, but cinder return connection_info has no 'device_path' key. So after that, 'device_path' key lost. modification scheme:as for vm has been connected the volume, check in source host that is of small significance. Unfortunately, this interface will trigger the volume add SAN mapping group again.This interface call is very time consuming. In addition, For some SAN, this behavior may trigger errors. So this patch set the parameter 'refresh_conn_info' to false in order to remove the interface initialize_connection call. Change-Id: Ice8882b0c0e838072526ed285648bb8840968072 Closes-Bug: #1582482 --- nova/compute/manager.py | 9 ++----- nova/tests/unit/compute/test_compute_mgr.py | 27 +-------------------- 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index dd4d27fc1ded..cb9ca9ffc16f 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -5021,13 +5021,8 @@ class ComputeManager(manager.Manager): migrate_data_obj.LiveMigrateData.detect_implementation( dest_check_data) dest_check_data.is_volume_backed = is_volume_backed - try: - block_device_info = self._get_instance_block_device_info( - ctxt, instance, refresh_conn_info=True) - except cinder_exception.ClientException as exc: - raise exception.MigrationPreCheckClientException( - reason=six.text_type(exc)) - + block_device_info = self._get_instance_block_device_info( + ctxt, instance, refresh_conn_info=False) result = self.driver.check_can_live_migrate_source(ctxt, instance, dest_check_data, block_device_info) diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 74a257fda9a0..52c905cf9348 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -1845,35 +1845,10 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): {'block_device_mapping': 'fake'}) mock_volume.assert_called_once_with(self.context, instance) mock_get_inst.assert_called_once_with(self.context, instance, - refresh_conn_info=True) + refresh_conn_info=False) self.assertTrue(dest_check_data.is_volume_backed) - def test_can_live_migrate_source_for_cinder_client_exception(self): - - is_volume_backed = 'volume_backed' - dest_check_data = migrate_data_obj.LiveMigrateData() - db_instance = fake_instance.fake_db_instance() - instance = objects.Instance._from_db_object( - self.context, objects.Instance(), db_instance) - - @mock.patch.object(compute_utils, 'EventReporter') - @mock.patch.object(compute_utils, 'add_instance_fault_from_exc') - @mock.patch.object(compute_utils, 'is_volume_backed_instance') - @mock.patch.object(self.compute, - '_get_instance_block_device_info') - def do_test(mock_block_info, mock_volume_backed, - mock_inst_fault, mock_event): - mock_volume_backed.return_value = is_volume_backed - mock_block_info.side_effect = cinder_exception.ClientException( - 'test', 'test') - - self.assertRaises(exception.MigrationPreCheckClientException, - self.compute.check_can_live_migrate_source, - self.context, instance, - dest_check_data) - do_test() - def _test_check_can_live_migrate_destination(self, do_raise=False): db_instance = fake_instance.fake_db_instance(host='fake-host') instance = objects.Instance._from_db_object(