diff --git a/doc/source/admin/config-trunking.rst b/doc/source/admin/config-trunking.rst index e9b68d3d923..2668c111113 100644 --- a/doc/source/admin/config-trunking.rst +++ b/doc/source/admin/config-trunking.rst @@ -72,6 +72,20 @@ Controller node [DEFAULT] service_plugins = trunk +Compute node +------------ + +* If you are using the ``Open vSwitch`` mechanism driver, then you can + verify the value of ``trunk_enabled`` flag in + ``/etc/neutron/plugins/ml2/openvswitch_agent.ini`` config file. + Note that ``True`` is the default value, but you can overwrite this + option like this: + + .. code-block:: ini + + [OVS] + trunk_enabled = True + Verify service operation ------------------------ diff --git a/neutron/conf/plugins/ml2/drivers/ovs_conf.py b/neutron/conf/plugins/ml2/drivers/ovs_conf.py index 9596c64bf61..3ff21017adf 100644 --- a/neutron/conf/plugins/ml2/drivers/ovs_conf.py +++ b/neutron/conf/plugins/ml2/drivers/ovs_conf.py @@ -185,6 +185,11 @@ ovs_opts = [ "limit features which will add meter kbps rules " "and apply them to the OpenFlow flow table " "BANDWIDTH_RATE_LIMIT for VM ports."), + cfg.BoolOpt('trunk_enabled', default=True, + help=_('Enable agent side trunk extension. If you do not ' + 'need the trunk extension, you can safely set ' + 'config option to False, it will avoid the agent ' + 'to declare some queues.')), ] agent_opts = [ diff --git a/neutron/services/trunk/drivers/openvswitch/agent/driver.py b/neutron/services/trunk/drivers/openvswitch/agent/driver.py index 3b027c8a901..d1b2e4c16b4 100644 --- a/neutron/services/trunk/drivers/openvswitch/agent/driver.py +++ b/neutron/services/trunk/drivers/openvswitch/agent/driver.py @@ -93,13 +93,13 @@ class OVSTrunkSkeleton(agent.TrunkSkeleton): def init_handler(resource, event, trigger, payload=None): """Handler for agent init event.""" - # Set up agent-side RPC for receiving trunk events; we may want to - # make this setup conditional based on server-side capabilities. global TRUNK_SKELETON - manager = trunk_manager.TrunkManager(trigger.int_br) - handler = ovsdb_handler.OVSDBHandler(manager) - TRUNK_SKELETON = OVSTrunkSkeleton(handler) + if cfg.CONF.OVS.trunk_enabled: + LOG.info("Registering Trunk extension") + manager = trunk_manager.TrunkManager(trigger.int_br) + handler = ovsdb_handler.OVSDBHandler(manager) + TRUNK_SKELETON = OVSTrunkSkeleton(handler) def unregister(): diff --git a/neutron/tests/unit/services/trunk/drivers/openvswitch/agent/test_driver.py b/neutron/tests/unit/services/trunk/drivers/openvswitch/agent/test_driver.py index d01f85ea11a..1a960149f12 100644 --- a/neutron/tests/unit/services/trunk/drivers/openvswitch/agent/test_driver.py +++ b/neutron/tests/unit/services/trunk/drivers/openvswitch/agent/test_driver.py @@ -13,6 +13,7 @@ from unittest import mock +from oslo_config import cfg import oslo_messaging from oslo_utils import uuidutils @@ -137,3 +138,25 @@ class OvsTrunkSkeletonTest(base.BaseTestCase): self.skeleton.ovsdb_handler, 'unwire_subports_for_trunk'): self._test_handle_subports_trunk_on_trunk_update( events.DELETED) + + +class InitHandlerTest(base.BaseTestCase): + + def setUp(self): + super().setUp() + # Unset the driver to avoid race condition between tests + driver.TRUNK_SKELETON = None + + def test_init_handler_plugin_default(self): + driver.init_handler(mock.Mock(), mock.Mock(), mock.Mock(), None) + self.assertIsInstance(driver.TRUNK_SKELETON, driver.OVSTrunkSkeleton) + + def test_init_handler_plugin_disabled(self): + cfg.CONF.set_override('trunk_enabled', False, group='OVS') + driver.init_handler(mock.Mock(), mock.Mock(), mock.Mock(), None) + self.assertFalse(driver.TRUNK_SKELETON) + + def test_init_handler_plugin_enabled(self): + cfg.CONF.set_override('trunk_enabled', True, group='OVS') + driver.init_handler(mock.Mock(), mock.Mock(), mock.Mock(), None) + self.assertIsInstance(driver.TRUNK_SKELETON, driver.OVSTrunkSkeleton) diff --git a/releasenotes/notes/skip-Trunk-ovs-extension-option-bbe5ef1a9fb89146.yaml b/releasenotes/notes/skip-Trunk-ovs-extension-option-bbe5ef1a9fb89146.yaml new file mode 100644 index 00000000000..76d7d70a370 --- /dev/null +++ b/releasenotes/notes/skip-Trunk-ovs-extension-option-bbe5ef1a9fb89146.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + An new option name ``trunk_enabled`` has been added to + ``neutron-openvswitch-agent`` under ``OVS`` group. This new option can be + set to ``False`` in order to disable loading the ``trunk`` extension on + agent side. The default value for this option is ``True`` to keep backward + compatibility with previous deployments. The recommendation is to set this + option to ``False`` if you do not use the ``trunk`` extension, so that + the number of queues created by the RPCServer will reduce. This can have + a very good impact on large-scale scenario using RabbitMQ message broker.