From 334dd0cb99d2bd43f7944c5ded12d61c97723765 Mon Sep 17 00:00:00 2001 From: marios Date: Wed, 22 Oct 2014 13:11:02 +0300 Subject: [PATCH] Reorder operations in (l3_dvr) update floating ip This review overrides update_floatingip (L3_NAT_dbonly_mixin) in l3_dvr_db (L3_NAT_with_dvr_db_mixin) to reorder the garbage collection to after the floating ip is updated and rpc called. This was previously being called in the (already) overridden _update_fip_assoc. Since this call is moved, the _update_fip_assoc for l3_dvr_db is exactly the same as l3_db and is thus removed completely. This tidy up was created whilst looking at bug 1381617. The intention was to mitigate the timing issues exposed by [1] and discussed in the bug report. It seems the problem persists with more discussion around 'properly fixing' this at [2]. [1] https://review.openstack.org/#/c/102700/ [2] https://review.openstack.org/#/c/130414/4 Change-Id: I24cef57bf394ceeb931ff48fa67f18218c734b00 --- neutron/db/l3_dvr_db.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index 1b39d5bed7..7845f9712f 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -142,19 +142,17 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, ) ) - def _update_fip_assoc(self, context, fip, floatingip_db, external_port): - previous_router_id = floatingip_db.router_id - port_id, internal_ip_address, router_id = ( - self._check_and_get_fip_assoc(context, fip, floatingip_db)) + def update_floatingip(self, context, id, floatingip): + res_fip = super(L3_NAT_with_dvr_db_mixin, self).update_floatingip( + context, id, floatingip) admin_ctx = context.elevated() - if (not ('port_id' in fip and fip['port_id'])) and ( - floatingip_db['fixed_port_id'] is not None): + fip = floatingip['floatingip'] + unused_agent_port = (fip.get('port_id', -1) is None and + res_fip.get('fixed_port_id')) + if unused_agent_port: self.clear_unused_fip_agent_gw_port( - admin_ctx, floatingip_db, fip['id']) - floatingip_db.update({'fixed_ip_address': internal_ip_address, - 'fixed_port_id': port_id, - 'router_id': router_id, - 'last_known_router_id': previous_router_id}) + admin_ctx, floatingip, fip['id']) + return res_fip def clear_unused_fip_agent_gw_port( self, context, floatingip_db, fip_id):