Fix driver filter to not check share_backend_name

Fixed the bug stating: Driver filter disallows using
queries with share_backend_name. The driver filter was
checking for hard equality between the share_backend_name
specified in the share type and the name reported by the
host [1]. This defeats the purpose of the capabilities
filter giving the ability to use "<in>" (selection)
operator in the extra-spec. Thus this commit fixes it by
updating the required files according to
openstack/cinder/commit/b32011 as now the driver does not
check for shared_backend_name.

Closes-Bug: #1815700

Change-Id: If384392d0f140922bb85a1dc50b0c4494c231e2f
(cherry picked from commit 86c1576110)
(cherry picked from commit ce370a1892)
(cherry picked from commit c75d48c067)
This commit is contained in:
snpd 2019-03-03 12:26:34 +05:30 committed by Goutham Pacha Ravi
parent a9f6638118
commit dee12e0841
3 changed files with 9 additions and 33 deletions

View File

@ -50,23 +50,9 @@ class DriverFilter(base_host.BaseHostFilter):
Returns a tuple in the format (filter_passing, filter_invalid).
Both values are booleans.
"""
host_stats = stats['host_stats']
extra_specs = stats['extra_specs']
# Check that the share types match
if extra_specs is None or 'share_backend_name' not in extra_specs:
LOG.warning("No 'share_backend_name' key in extra_specs. "
"Skipping share backend name check.")
elif (extra_specs['share_backend_name'] !=
host_stats['share_backend_name']):
LOG.warning("Share backend names do not match: '%(target)s'"
"vs '%(current)s' :: Skipping.",
{'target': extra_specs['share_backend_name'],
'current': host_stats['share_backend_name']})
return False
if stats['filter_function'] is None:
LOG.warning("Filter function not set :: passing host.")
LOG.debug("Filter function not set :: passing host.")
return True
try:

View File

@ -82,24 +82,6 @@ class HostFiltersTestCase(test.TestCase):
self.assertTrue(self.filter.host_passes(host1, filter_properties))
def test_extra_specs_wrong_backend(self):
host1 = fakes.FakeHostState(
'host1', {
'capabilities': {
'filter_function': '1 == 1',
}
})
filter_properties = {
'share_type': {
'extra_specs': {
'share_backend_name': 'foo',
}
}
}
self.assertFalse(self.filter.host_passes(host1, filter_properties))
def test_function_extra_spec_replacement(self):
host1 = fakes.FakeHostState(
'host1', {

View File

@ -0,0 +1,8 @@
---
fixes:
- |
Fixed the driver filter to not check for hard equality between the
share_backend_name and the name reported by the host as it defeats the
purpose of the capabilities filter giving the ability to use "<in>"
selection operator in the extra-spec. Refer to `Launchpad bug 1815700
<https://bugs.launchpad.net/manila/+bug/1815700>`_ for more details.