From db2207f32d2b88772966e4e2a4f10e2ad66fcf49 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Wed, 26 May 2021 12:52:39 +0200 Subject: [PATCH] [ML2] Change way how list of supported API extensions is made Previously if extension was not supported by one of the mech drivers, but it wasn't filtered out by next mech driver, it was available finally in the list. Now, this patch changes that so if extension is disabled by one of the drivers it isn't available on the list at all. This will work better e.g. with discoverability of what is available e.g. when OVN backend is used by Neutron. Closes-Bug: #1929676 Change-Id: I6a4ff42f47f7ee90365516d37472c09ac87773e5 --- neutron/plugins/ml2/plugin.py | 6 +++--- neutron/tests/unit/plugins/ml2/test_plugin.py | 5 ++--- ...xtensions-are-filtered-out-b4449e690cb64480.yaml | 13 +++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/change-the-way-how-api-extensions-are-filtered-out-b4449e690cb64480.yaml diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index d92aa536cfd..55c49b5d1ee 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -313,10 +313,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, if not self.mechanism_manager.ordered_mech_drivers: return aliases - supported_extensions = set([]) + supported_extensions = set(aliases) for mech_driver in self.mechanism_manager.ordered_mech_drivers: - supported_extensions |= mech_driver.obj.supported_extensions( - set(aliases)) + supported_extensions &= mech_driver.obj.supported_extensions( + supported_extensions) return list(supported_extensions) @registry.receives(resources.PORT, diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index cf4db6176cd..e39ac51a3a2 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -177,15 +177,14 @@ class TestMl2FilterExtensions(Ml2PluginV2TestCase): def test__filter_extensions_by_mech_driver(self): extension_aliases = ['ext1', 'ext2', 'ext3', 'ext4', 'ext5'] supported_aliases = [{'ext0', 'ext1', 'ext2'}, - {'ext4', 'ext5', 'ext6'}] + {'ext1', 'ext5', 'ext6'}] for idx, mech_driver in enumerate( self.plugin.mechanism_manager.ordered_mech_drivers): mech_driver.obj._supported_extensions = supported_aliases[idx] supported_extensions = sorted( self.plugin._filter_extensions_by_mech_driver(extension_aliases)) - self.assertEqual(['ext1', 'ext2', 'ext4', 'ext5'], - supported_extensions) + self.assertEqual(['ext1'], supported_extensions) class TestMl2BasicGet(test_plugin.TestBasicGet, diff --git a/releasenotes/notes/change-the-way-how-api-extensions-are-filtered-out-b4449e690cb64480.yaml b/releasenotes/notes/change-the-way-how-api-extensions-are-filtered-out-b4449e690cb64480.yaml new file mode 100644 index 00000000000..7d2181bfea2 --- /dev/null +++ b/releasenotes/notes/change-the-way-how-api-extensions-are-filtered-out-b4449e690cb64480.yaml @@ -0,0 +1,13 @@ +--- +upgrade: + - | + The way the ML2 plugin filters out API extensions which are not supported + by loaded mechanism drivers has changed. + Before, the API extension was on the list if at least one of the mechanism drivers + supported it, but now the extension needs to be supported by all the mechanism + drivers. If at least one of them filters it out, it will be removed from + the final list of enabled API extensions. + Currently, only the OVN mechanism driver is filtering out some of the ML2 + API extensions, thus if that mechanism driver is loaded in Neutron with any other + mechanism driver, the list of the enabled API extensions may be smaller than it + was before.