From dee12e0841d55dd80b3bb3b4926749c70fa86190 Mon Sep 17 00:00:00 2001 From: snpd Date: Sun, 3 Mar 2019 12:26:34 +0530 Subject: [PATCH] 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 "" (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 86c1576110f9e6d92ea539c2a2b16f46d325f6ee) (cherry picked from commit ce370a1892ed5e1820d55008acb2e87abc7b9db8) (cherry picked from commit c75d48c067875609f5e0dcc1c8f6896f55af9fbd) --- manila/scheduler/filters/driver.py | 16 +--------------- manila/tests/scheduler/filters/test_driver.py | 18 ------------------ .../fixing-driver-filter-14022294c8c04d2d.yaml | 8 ++++++++ 3 files changed, 9 insertions(+), 33 deletions(-) create mode 100644 releasenotes/notes/fixing-driver-filter-14022294c8c04d2d.yaml diff --git a/manila/scheduler/filters/driver.py b/manila/scheduler/filters/driver.py index 9b2bbe7746..539bad76dd 100644 --- a/manila/scheduler/filters/driver.py +++ b/manila/scheduler/filters/driver.py @@ -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: diff --git a/manila/tests/scheduler/filters/test_driver.py b/manila/tests/scheduler/filters/test_driver.py index 7c54e18691..2cf07a4e93 100644 --- a/manila/tests/scheduler/filters/test_driver.py +++ b/manila/tests/scheduler/filters/test_driver.py @@ -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', { diff --git a/releasenotes/notes/fixing-driver-filter-14022294c8c04d2d.yaml b/releasenotes/notes/fixing-driver-filter-14022294c8c04d2d.yaml new file mode 100644 index 0000000000..e897e95d6a --- /dev/null +++ b/releasenotes/notes/fixing-driver-filter-14022294c8c04d2d.yaml @@ -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 "" + selection operator in the extra-spec. Refer to `Launchpad bug 1815700 + `_ for more details.