diff --git a/manila/scheduler/drivers/filter.py b/manila/scheduler/drivers/filter.py index cea54458b3..ca8f3f6075 100644 --- a/manila/scheduler/drivers/filter.py +++ b/manila/scheduler/drivers/filter.py @@ -174,6 +174,11 @@ class FilterScheduler(base.Scheduler): if ar_host: replication_domain = ar_host.replication_domain + # NOTE(zengyingzhe): remove the 'share_backend_name' extra spec, + # let scheduler choose the available host for this replica + # creation request. + share_type.get('extra_specs', {}).pop('share_backend_name', None) + if filter_properties is None: filter_properties = {} self._populate_retry_share(filter_properties, resource_properties) diff --git a/manila/tests/scheduler/drivers/test_filter.py b/manila/tests/scheduler/drivers/test_filter.py index 5e3ba778cc..0097249bde 100644 --- a/manila/tests/scheduler/drivers/test_filter.py +++ b/manila/tests/scheduler/drivers/test_filter.py @@ -60,6 +60,35 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase): self.assertIn('replication_domain', retval[0]) + @ddt.data(True, False) + def test__format_filter_properties_backend_specified_for_replica( + self, has_share_backend_name): + sched = fakes.FakeFilterScheduler() + fake_context = context.RequestContext('user', 'project') + request_spec = { + 'share_properties': {'project_id': 1, 'size': 1}, + 'share_instance_properties': {}, + 'share_type': { + 'name': 'NFS', + 'extra_specs': {}, + }, + 'share_id': 'fake-id1', + 'active_replica_host': 'fake_ar_host', + } + + if has_share_backend_name: + request_spec['share_type']['extra_specs'].update( + {'share_backend_name': 'fake_backend'}) + + self.mock_object(sched.host_manager, 'get_all_host_states_share', + mock.Mock(return_value=[])) + + retval = sched._format_filter_properties( + fake_context, {}, request_spec) + + self.assertNotIn('share_backend_name', + retval[0]['share_type']['extra_specs']) + def test_create_share_no_hosts(self): # Ensure empty hosts/child_zones result in NoValidHosts exception. sched = fakes.FakeFilterScheduler() diff --git a/releasenotes/notes/bug-1634734-fix-backend-extraspec-for-replication-d611d2227997ae3e.yaml b/releasenotes/notes/bug-1634734-fix-backend-extraspec-for-replication-d611d2227997ae3e.yaml new file mode 100644 index 0000000000..9cbb838b11 --- /dev/null +++ b/releasenotes/notes/bug-1634734-fix-backend-extraspec-for-replication-d611d2227997ae3e.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Share type extra-specification ``share_backend_name`` is now ignored when + creating share replicas. This ensures that backends in the same + replication domain need not have the same value of ``share_backend_name``. + See `launchpad bug #1634734 `_ + for details.