Merge "Force share server selection on nondisruptive migration"
This commit is contained in:
commit
5b6197821b
@ -1073,10 +1073,24 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if dest_share_instance['share_network_id']:
|
if dest_share_instance['share_network_id']:
|
||||||
|
# NOTE(carloss): For a nondisruptive migration request, we must
|
||||||
|
# not change the share server, otherwise the share's export
|
||||||
|
# location will change, disconnecting the user. Disruptive
|
||||||
|
# migration requests to the driver the share server.
|
||||||
|
if nondisruptive:
|
||||||
|
dest_share_server = self._get_share_server_dict(
|
||||||
|
context, share_server)
|
||||||
|
dest_share_instance = self.db.share_instance_update(
|
||||||
|
context,
|
||||||
|
dest_share_instance['id'],
|
||||||
|
{'share_server_id': dest_share_server['id']},
|
||||||
|
with_share_data=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
rpcapi = share_rpcapi.ShareAPI()
|
rpcapi = share_rpcapi.ShareAPI()
|
||||||
|
|
||||||
# NOTE(ganso): Obtaining the share_server_id asynchronously so
|
# NOTE(ganso): Obtaining the share_server_id asynchronously
|
||||||
# we can wait for it to be ready.
|
# so we can wait for it to be ready.
|
||||||
dest_share_server_id = rpcapi.provide_share_server(
|
dest_share_server_id = rpcapi.provide_share_server(
|
||||||
context, dest_share_instance,
|
context, dest_share_instance,
|
||||||
dest_share_instance['share_network_id'])
|
dest_share_instance['share_network_id'])
|
||||||
@ -1086,6 +1100,7 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||||||
|
|
||||||
dest_share_server = helper.wait_for_share_server(
|
dest_share_server = helper.wait_for_share_server(
|
||||||
dest_share_server_id)
|
dest_share_server_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
dest_share_server = None
|
dest_share_server = None
|
||||||
|
|
||||||
|
@ -5466,6 +5466,8 @@ class ShareManagerTestCase(test.TestCase):
|
|||||||
self.mock_object(
|
self.mock_object(
|
||||||
migration_api.ShareMigrationHelper, 'wait_for_share_server',
|
migration_api.ShareMigrationHelper, 'wait_for_share_server',
|
||||||
mock.Mock(return_value=dest_server))
|
mock.Mock(return_value=dest_server))
|
||||||
|
self.mock_object(self.share_manager.db, 'share_instance_update',
|
||||||
|
mock.Mock(return_value=migrating_instance))
|
||||||
self.mock_object(self.share_manager, '_migration_delete_instance')
|
self.mock_object(self.share_manager, '_migration_delete_instance')
|
||||||
self.mock_object(self.share_manager.driver,
|
self.mock_object(self.share_manager.driver,
|
||||||
'migration_check_compatibility',
|
'migration_check_compatibility',
|
||||||
@ -5480,7 +5482,7 @@ class ShareManagerTestCase(test.TestCase):
|
|||||||
exception.ShareMigrationFailed,
|
exception.ShareMigrationFailed,
|
||||||
self.share_manager._migration_start_driver,
|
self.share_manager._migration_start_driver,
|
||||||
self.context, share, src_instance, fake_dest_host, True, True,
|
self.context, share, src_instance, fake_dest_host, True, True,
|
||||||
True, not has_snapshots, 'fake_net_id', 'fake_az_id',
|
nondisruptive, not has_snapshots, 'fake_net_id', 'fake_az_id',
|
||||||
'fake_new_type_id')
|
'fake_new_type_id')
|
||||||
|
|
||||||
# asserts
|
# asserts
|
||||||
@ -5488,6 +5490,15 @@ class ShareManagerTestCase(test.TestCase):
|
|||||||
utils.IsAMatcher(context.RequestContext), 'src_server_id')
|
utils.IsAMatcher(context.RequestContext), 'src_server_id')
|
||||||
self.share_manager.db.share_instance_get.assert_called_once_with(
|
self.share_manager.db.share_instance_get.assert_called_once_with(
|
||||||
self.context, migrating_instance['id'], with_share_data=True)
|
self.context, migrating_instance['id'], with_share_data=True)
|
||||||
|
if nondisruptive:
|
||||||
|
self.share_manager.db.share_instance_update.assert_called_with(
|
||||||
|
self.context, migrating_instance['id'],
|
||||||
|
{'share_server_id': src_server['id']},
|
||||||
|
with_share_data=True
|
||||||
|
)
|
||||||
|
rpcapi.ShareAPI.provide_share_server.assert_not_called()
|
||||||
|
rpcapi.ShareAPI.create_share_server.assert_not_called()
|
||||||
|
else:
|
||||||
(rpcapi.ShareAPI.provide_share_server.
|
(rpcapi.ShareAPI.provide_share_server.
|
||||||
assert_called_once_with(
|
assert_called_once_with(
|
||||||
self.context, migrating_instance, 'fake_net_id'))
|
self.context, migrating_instance, 'fake_net_id'))
|
||||||
@ -5495,6 +5506,7 @@ class ShareManagerTestCase(test.TestCase):
|
|||||||
self.context, migrating_instance, 'fake_dest_share_server_id')
|
self.context, migrating_instance, 'fake_dest_share_server_id')
|
||||||
(migration_api.ShareMigrationHelper.wait_for_share_server.
|
(migration_api.ShareMigrationHelper.wait_for_share_server.
|
||||||
assert_called_once_with('fake_dest_share_server_id'))
|
assert_called_once_with('fake_dest_share_server_id'))
|
||||||
|
|
||||||
(api.API.create_share_instance_and_get_request_spec.
|
(api.API.create_share_instance_and_get_request_spec.
|
||||||
assert_called_once_with(self.context, share, 'fake_az_id', None,
|
assert_called_once_with(self.context, share, 'fake_az_id', None,
|
||||||
'fake_host', 'fake_net_id',
|
'fake_host', 'fake_net_id',
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Non-disruptive share migration will no longer choose a different
|
||||||
|
destination server even if limits of shares or gigabytes were exceeded in
|
||||||
|
the source.
|
||||||
|
For more details, please see
|
||||||
|
`bug #1920942 <https://bugs.launchpad.net/manila/+bug/1920942>`_.
|
Loading…
Reference in New Issue
Block a user