Browse Source

Merge "Always add NAT rule to a LR when updating a FIP" into stable/queens

changes/41/678241/1
Zuul 1 month ago
parent
commit
853ddae0f6
2 changed files with 5 additions and 21 deletions
  1. 3
    18
      networking_ovn/common/ovn_client.py
  2. 2
    3
      networking_ovn/tests/unit/l3/test_l3_ovn.py

+ 3
- 18
networking_ovn/common/ovn_client.py View File

@@ -565,9 +565,7 @@ class OVNClient(object):
565 565
         context = n_context.get_admin_context()
566 566
         fip_db = self._l3_plugin._get_floatingip(context, floatingip['id'])
567 567
 
568
-        func = self._nb_idl.add_nat_rule_in_lrouter
569 568
         gw_lrouter_name = utils.ovn_name(router_id)
570
-        nat_rule_args = (gw_lrouter_name,)
571 569
         # TODO(chandrav): Since the floating ip port is not
572 570
         # bound to any chassis, packets destined to floating ip
573 571
         # will be dropped. To overcome this, delete the floating
@@ -578,21 +576,6 @@ class OVNClient(object):
578 576
                         fip_db['floating_port_id'],
579 577
                         utils.ovn_name(floatingip['floating_network_id'])))
580 578
 
581
-        # Get the list of nat rules and check if the external_ip
582
-        # with type 'dnat_and_snat' already exists or not.
583
-        # If exists, set the new value.
584
-        # This happens when the port associated to a floating ip
585
-        # is deleted before the disassociation.
586
-        lrouter_nat_rules = self._nb_idl.get_lrouter_nat_rules(
587
-            gw_lrouter_name)
588
-        for nat_rule in lrouter_nat_rules:
589
-            if (nat_rule['external_ip'] ==
590
-                    floatingip['floating_ip_address'] and
591
-                    nat_rule['type'] == 'dnat_and_snat'):
592
-                func = self._nb_idl.set_nat_rule_in_lrouter
593
-                nat_rule_args = (gw_lrouter_name, nat_rule['uuid'])
594
-                break
595
-
596 579
         ext_ids = {
597 580
             ovn_const.OVN_FIP_EXT_ID_KEY: floatingip['id'],
598 581
             ovn_const.OVN_REV_NUM_EXT_ID_KEY: str(utils.get_revision_number(
@@ -619,7 +602,9 @@ class OVNClient(object):
619 602
         if self._nb_idl.is_col_present('NAT', 'external_ids'):
620 603
             columns['external_ids'] = ext_ids
621 604
 
622
-        commands.append(func(*nat_rule_args, **columns))
605
+        commands.append(self._nb_idl.add_nat_rule_in_lrouter(gw_lrouter_name,
606
+                                                             **columns))
607
+
623 608
         self._transaction(commands, txn=txn)
624 609
 
625 610
     def _delete_floatingip(self, fip, lrouter, txn=None):

+ 2
- 3
networking_ovn/tests/unit/l3/test_l3_ovn.py View File

@@ -849,7 +849,6 @@ class OVNL3RouterPlugin(test_mech_driver.OVNMechanismDriverTestCase):
849 849
             {'external_ip': '192.168.0.10', 'logical_ip': '10.0.0.6',
850 850
              'type': 'dnat_and_snat', 'uuid': 'uuid1'}]
851 851
         self.l3_inst.create_floatingip(self.context, 'floatingip')
852
-        self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_not_called()
853 852
         expected_ext_ids = {
854 853
             ovn_const.OVN_FIP_EXT_ID_KEY: self.fake_floating_ip['id'],
855 854
             ovn_const.OVN_REV_NUM_EXT_ID_KEY: '1',
@@ -857,8 +856,8 @@ class OVNL3RouterPlugin(test_mech_driver.OVNMechanismDriverTestCase):
857 856
                 self.fake_floating_ip['port_id'],
858 857
             ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY: utils.ovn_name(
859 858
                 self.fake_floating_ip['router_id'])}
860
-        self.l3_inst._ovn.set_nat_rule_in_lrouter.assert_called_once_with(
861
-            'neutron-router-id', 'uuid1',
859
+        self.l3_inst._ovn.add_nat_rule_in_lrouter.assert_called_once_with(
860
+            'neutron-router-id',
862 861
             type='dnat_and_snat',
863 862
             logical_ip='10.0.0.10',
864 863
             external_ip='192.168.0.10',

Loading…
Cancel
Save