From 31a15fdd6d7b52415ca250a63b31bf841564e92a Mon Sep 17 00:00:00 2001 From: elajkat Date: Tue, 5 Jul 2022 09:57:54 +0200 Subject: [PATCH] [sqlalchemy-20] Remove retry decorator from update_floatingip_status L3_NAT_dbonly_mixin.update_floatingip_status is called from methods which are decoarted with retry decorator or from within a db context. As update_floatingip_status also called from OVNL3RouterPlugin added a utility method, update_floatingip_status_retry with decorator to avoid retrying OVN methods, and added CONTEXT_WRITER here also as other calls of update_floatingip_status from l3_rpc for example uses CONTEXT_WRITER. Change-Id: Ifdb008c2402aa24766cbd30dd53458599076c955 Closes-Bug: #1980721 --- neutron/db/l3_db.py | 1 - neutron/services/ovn_l3/plugin.py | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 4e3eff0ad48..6beeee0e664 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -1551,7 +1551,6 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase, context, id, floatingip) return floatingip - @db_api.retry_if_session_inactive() def update_floatingip_status(self, context, floatingip_id, status): """Update operational status for floating IP in neutron DB.""" return l3_obj.FloatingIP.update_object( diff --git a/neutron/services/ovn_l3/plugin.py b/neutron/services/ovn_l3/plugin.py index 60766fd25dd..a2897fe79c4 100644 --- a/neutron/services/ovn_l3/plugin.py +++ b/neutron/services/ovn_l3/plugin.py @@ -22,6 +22,7 @@ from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources from neutron_lib import constants as n_const from neutron_lib import context as n_context +from neutron_lib.db import api as db_api from neutron_lib import exceptions as n_exc from neutron_lib.exceptions import availability_zone as az_exc from neutron_lib.plugins import constants as plugin_constants @@ -288,11 +289,17 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase, return fip def update_floatingip_status(self, context, floatingip_id, status): - fip = super(OVNL3RouterPlugin, self).update_floatingip_status( + fip = self.update_floatingip_status_retry( context, floatingip_id, status) self._ovn_client.update_floatingip_status(context, fip) return fip + @db_api.retry_if_session_inactive() + def update_floatingip_status_retry(self, context, floatingip_id, status): + with db_api.CONTEXT_WRITER.using(context): + return super(OVNL3RouterPlugin, self).update_floatingip_status( + context, floatingip_id, status) + def disassociate_floatingips(self, context, port_id, do_notify=True): fips = self.get_floatingips(context.elevated(), filters={'port_id': [port_id]})