diff --git a/manila/share/manager.py b/manila/share/manager.py index fb44014e46..610d9d1ab7 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -258,7 +258,7 @@ class ShareManager(manager.SchedulerDependentManager): if pool: new_host = share_utils.append_host( share_instance['host'], pool) - self.db.share_update( + self.db.share_instance_update( ctxt, share_instance['id'], {'host': new_host}) return pool diff --git a/manila/tests/share/test_manager.py b/manila/tests/share/test_manager.py index d082eb5273..fe8ec7acc4 100644 --- a/manila/tests/share/test_manager.py +++ b/manila/tests/share/test_manager.py @@ -2832,6 +2832,21 @@ class ShareManagerTestCase(test.TestCase): context.get_admin_context(), fake_share) self.assertEqual(1, mock_LOG.exception.call_count) + def test_ensure_share_instance_pool_notexist_and_get_from_driver(self): + fake_share_instance = {'host': 'host@backend', 'id': 1, + 'status': constants.STATUS_AVAILABLE} + fake_host_expected_value = 'fake_pool' + self.mock_object(self.share_manager.db, 'share_instance_update') + self.mock_object(self.share_manager.driver, 'get_pool', + mock.Mock(return_value='fake_pool')) + + host = self.share_manager._ensure_share_instance_has_pool( + context.get_admin_context(), fake_share_instance) + + self.share_manager.db.share_instance_update.assert_any_call( + mock.ANY, 1, {'host': 'host@backend#fake_pool'}) + self.assertEqual(fake_host_expected_value, host) + def test__form_server_setup_info(self): def fake_network_allocations_get_for_share_server(*args, **kwargs): if kwargs.get('label') != 'admin': diff --git a/releasenotes/notes/bug-1684032-6e4502fdceb693dr7.yaml b/releasenotes/notes/bug-1684032-6e4502fdceb693dr7.yaml new file mode 100644 index 0000000000..4fbe750b8a --- /dev/null +++ b/releasenotes/notes/bug-1684032-6e4502fdceb693dr7.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - When upgrading manila to a new release, if a share driver has added + support for storage pools in the new release, shares belonging to + such drivers would be iteratively updated by manila. This is done by + querying the back end driver for the storage pool that each share is + hosted within. A bug affecting the database update in this path has + been fixed.