From 346cebcbbb519d07d98ce60cd2d388ff00a0ce25 Mon Sep 17 00:00:00 2001 From: silvacarloss Date: Fri, 11 Sep 2020 11:59:21 +0000 Subject: [PATCH] Follow up change for share server migration Addresses few observed issues in the share server migration core change. Change-Id: Ib20faed6d8597f1b7a645f5674f5797e3d3e5ded --- ... 5aa813ae673d_add_task_state_field_for_share_servers.py} | 0 manila/share/api.py | 3 +-- manila/share/manager.py | 6 +++--- .../tests/db/migrations/alembic/migrations_data_checks.py | 2 ++ manila/tests/share/test_manager.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) rename manila/db/migrations/alembic/versions/{5aa813ae673d_add_task_state_field_for_share_servers_.py => 5aa813ae673d_add_task_state_field_for_share_servers.py} (100%) diff --git a/manila/db/migrations/alembic/versions/5aa813ae673d_add_task_state_field_for_share_servers_.py b/manila/db/migrations/alembic/versions/5aa813ae673d_add_task_state_field_for_share_servers.py similarity index 100% rename from manila/db/migrations/alembic/versions/5aa813ae673d_add_task_state_field_for_share_servers_.py rename to manila/db/migrations/alembic/versions/5aa813ae673d_add_task_state_field_for_share_servers.py diff --git a/manila/share/api.py b/manila/share/api.py index cee4d7de1d..8ec8af6b3f 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -2600,8 +2600,7 @@ class API(base.Base): 'task_state': dest_share_server['task_state'], } # Source server still exists so it must be in 'server_migrating' status - if (share_server and - share_server['status'] != constants.STATUS_SERVER_MIGRATING): + if share_server['status'] != constants.STATUS_SERVER_MIGRATING: msg = _("Migration progress of share server %s cannot be " "obtained. The provided share server is not being " "migrated.") % share_server['id'] diff --git a/manila/share/manager.py b/manila/share/manager.py index 883fc8925f..acf78d89d7 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -1103,7 +1103,7 @@ class ShareManager(manager.SchedulerDependentManager): def _cast_access_rules_to_readonly(self, context, src_share_instance, share_server, dest_host=None): self._cast_access_rules_to_readonly_for_server( - context, [src_share_instance], share_server, dest_host) + context, [src_share_instance], share_server, dest_host=dest_host) def _cast_access_rules_to_readonly_for_server( self, context, src_share_instances, share_server, dest_host=None): @@ -4873,7 +4873,7 @@ class ShareManager(manager.SchedulerDependentManager): # driver doesn't support 'writable'. self._cast_access_rules_to_readonly_for_server( context, share_instances, source_share_server, - source_share_server['host']) + dest_host=source_share_server['host']) LOG.debug("Initiating driver migration for share server %s.", source_share_server['id']) @@ -5012,7 +5012,7 @@ class ShareManager(manager.SchedulerDependentManager): try: if not self.driver.driver_handles_share_servers: LOG.error('This operation is supported only on backends that ' - 'handles share servers.') + 'handle share servers.') raise self._share_server_migration_start_driver( diff --git a/manila/tests/db/migrations/alembic/migrations_data_checks.py b/manila/tests/db/migrations/alembic/migrations_data_checks.py index ebe79f841d..8f127ac0d5 100644 --- a/manila/tests/db/migrations/alembic/migrations_data_checks.py +++ b/manila/tests/db/migrations/alembic/migrations_data_checks.py @@ -2966,6 +2966,8 @@ class ShareServerTaskState(BaseMigrationChecks): for ss in engine.execute(ss_table.select()): self.test_case.assertTrue(hasattr(ss, 'task_state')) self.test_case.assertTrue(hasattr(ss, 'source_share_server_id')) + self.test_case.assertIsNone(ss['task_state']) + self.test_case.assertIsNone(ss['source_share_server_id']) def check_downgrade(self, engine): ss_table = utils.load_table('share_servers', engine) diff --git a/manila/tests/share/test_manager.py b/manila/tests/share/test_manager.py index 49abb6bc71..d3bc756a11 100644 --- a/manila/tests/share/test_manager.py +++ b/manila/tests/share/test_manager.py @@ -8032,7 +8032,7 @@ class ShareManagerTestCase(test.TestCase): (self.share_manager._cast_access_rules_to_readonly_for_server. assert_called_once_with( self.context, fake_share_instances, fake_old_share_server, - fake_old_share_server['host'])) + dest_host=fake_old_share_server['host'])) else: (self.share_manager._cast_access_rules_to_readonly_for_server. assert_not_called())