Fix update share instance pool fail

The share instance doesn't have pool value in host property,
We cannot update share instance pool when we restart manila
share service, becuase we use share_update DB function to update
share instance attribute. Now we are changing share_update to
share_instance_update.

Change-Id: Ief7e70103ed63bbb2f78d0f9eed8351f8470d414
Closes-Bug: #1684032
This commit is contained in:
zhongjun 2017-04-19 15:43:55 +08:00 committed by zhongjun
parent 4e25ce5a0c
commit 9ecb77bf4b
3 changed files with 24 additions and 1 deletions

View File

@ -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

View File

@ -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':

View File

@ -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.