From 559ae06bdf1f11ca861234a92434771a26ec27d8 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Thu, 4 Jun 2020 10:35:50 +0200 Subject: [PATCH] [OVN] Override notify_nova config in neutron-ovn-db-sync-util If either ``notify_nova_on_port_status_changes`` or ``notify_nova_on_port_data_changes`` is set in the neutron configuration provided to the ``neutron-ovn-db-sync-util`` tool it will stop with a Traceback. We are already overriding other parts of the ML2 Notification code as we do not want it executing while syncing, so let's override these configuration options if set as well. Change-Id: I62765a14d376664ccc2ca3009bb9e970c9f25c03 Closes-Bug: #1882020 --- neutron/cmd/ovn/neutron_ovn_db_sync_util.py | 3 ++ neutron/tests/unit/cmd/ovn/__init__.py | 0 .../cmd/ovn/test_neutron_ovn_db_sync_util.py | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 neutron/tests/unit/cmd/ovn/__init__.py create mode 100644 neutron/tests/unit/cmd/ovn/test_neutron_ovn_db_sync_util.py diff --git a/neutron/cmd/ovn/neutron_ovn_db_sync_util.py b/neutron/cmd/ovn/neutron_ovn_db_sync_util.py index fd78bf2163e..906cc1a60c9 100644 --- a/neutron/cmd/ovn/neutron_ovn_db_sync_util.py +++ b/neutron/cmd/ovn/neutron_ovn_db_sync_util.py @@ -143,6 +143,9 @@ def setup_conf(): cfg.CONF.register_cli_opts(ovn_opts, group=ovn_group) db_group, neutron_db_opts = db_options.list_opts()[0] cfg.CONF.register_cli_opts(neutron_db_opts, db_group) + # Override Nova notify configuration LP: #1882020 + cfg.CONF.set_override('notify_nova_on_port_status_changes', False) + cfg.CONF.set_override('notify_nova_on_port_data_changes', False) return conf diff --git a/neutron/tests/unit/cmd/ovn/__init__.py b/neutron/tests/unit/cmd/ovn/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/neutron/tests/unit/cmd/ovn/test_neutron_ovn_db_sync_util.py b/neutron/tests/unit/cmd/ovn/test_neutron_ovn_db_sync_util.py new file mode 100644 index 00000000000..bd0956f0bc6 --- /dev/null +++ b/neutron/tests/unit/cmd/ovn/test_neutron_ovn_db_sync_util.py @@ -0,0 +1,31 @@ +# Copyright 2020 Canonical Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + +from neutron.cmd.ovn import neutron_ovn_db_sync_util as util +from neutron.tests import base + + +class TestNeutronOVNDBSyncUtil(base.BaseTestCase): + + def test_setup_conf(self): + # the code under test will fail because of the cfg.conf alredy being + # initialized by the BaseTestCase setUp method. Reset. + cfg.CONF.reset() + util.setup_conf() + # The sync tool will fail if these config options are at their default + # value. Validate that the setup code overrides them. LP: #1882020 + self.assertFalse(cfg.CONF.notify_nova_on_port_status_changes) + self.assertFalse(cfg.CONF.notify_nova_on_port_data_changes)