From 0745e32cd2bfacb11754814d30392d97e87c23b9 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Wed, 21 Nov 2018 12:21:56 +0100 Subject: [PATCH] DVR Floating IP create don't raise exception if agent not found Patch [1] added handling of AgentNotFoundByTypeHost exception in create_fip_agent_gw_port_if_not_exists method in neutron.db.l3_dvr_db.DVRResourceOperationHandler class. Unfortunatelly there was mistake there and such exception wasn't catched properly. That caused issue e.g. in functional-python35 tests but wasn't catched properly in functional tests using python27. This patch changes this to handle such exception properly. [1] https://review.openstack.org/#/c/574917/ Change-Id: If43f2c944ff46d8b05fbcf68231fd04bed147ba0 --- neutron/db/l3_dvr_db.py | 3 +-- .../services/l3_router/test_l3_dvr_router_plugin.py | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index 66f4845fdf7..2301334b8d2 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -983,8 +983,7 @@ class _DVRAgentInterfaceMixin(object): try: l3_agent_db = self._get_agent_by_type_and_host( context, const.AGENT_TYPE_L3, host) - except agent_exc.AgentNotFoundByTypeHost( - agent_type=const.AGENT_TYPE_L3, host=host): + except agent_exc.AgentNotFoundByTypeHost: LOG.warning("%(ag)s agent not found for the given host: %(host)s", {'ag': const.AGENT_TYPE_L3, 'host': host}) diff --git a/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py b/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py index a9da99afabe..9d405717690 100644 --- a/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py +++ b/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py @@ -20,7 +20,6 @@ from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources -from neutron_lib.exceptions import agent as agent_exc from neutron_lib import constants from neutron_lib import context @@ -338,12 +337,9 @@ class L3DvrTestCase(L3DvrTestCaseBase): self.context, router['id'], {'subnet_id': int_subnet['subnet']['id']}) if test_agent_mode is None: - self.assertRaises( - agent_exc.AgentNotFoundByTypeHost, - self.l3_plugin.create_fip_agent_gw_port_if_not_exists, - self.context, - ext_net_id, - 'host1') + self.assertIsNone( + self.l3_plugin.create_fip_agent_gw_port_if_not_exists( + self.context, ext_net_id, 'host1')) return floating_ip = {'floating_network_id': ext_net_id, 'router_id': router['id'],