Remove backend spec from share type while creating replica

If a share type includes the share_backend_name spec,
the scheduler may fail to schedule share replicas unless
all backends in a replication domain share the same
value for the capability "share_backend_name". Having
the same "share_backend_name" isn't desirable all the
time.

Ignore the share_backend_name spec from share type
while creating replica, so the scheduler will filter
a available backend according to the selection policy.

Change-Id: Ic8f7e6230298c222cc6cb5e4e4e8189524aaa81f
Closes-Bug: #1634734
This commit is contained in:
zengyingzhe 2016-10-28 15:26:22 +08:00 committed by Goutham Pacha Ravi
parent f1e10ec2ff
commit 700c1a02f0
3 changed files with 42 additions and 0 deletions

View File

@ -174,6 +174,11 @@ class FilterScheduler(base.Scheduler):
if ar_host: if ar_host:
replication_domain = ar_host.replication_domain 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: if filter_properties is None:
filter_properties = {} filter_properties = {}
self._populate_retry_share(filter_properties, resource_properties) self._populate_retry_share(filter_properties, resource_properties)

View File

@ -60,6 +60,35 @@ class FilterSchedulerTestCase(test_base.SchedulerTestCase):
self.assertIn('replication_domain', retval[0]) 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): def test_create_share_no_hosts(self):
# Ensure empty hosts/child_zones result in NoValidHosts exception. # Ensure empty hosts/child_zones result in NoValidHosts exception.
sched = fakes.FakeFilterScheduler() sched = fakes.FakeFilterScheduler()

View File

@ -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 <https://bugs.launchpad.net/manila/+bug/1634734>`_
for details.