Skip to content

Commit b0a90af

Browse files
committed
Revert: Ensure traffic is not centralized if DVR is enabled
This patch breaks FIPs on LBs when Neutron is restarted. See bug: https://bugs.launchpad.net/neutron/+bug/2042938
1 parent a680d58 commit b0a90af

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ def get_workers(self):
10611061
# See doc/source/design/ovn_worker.rst for more details.
10621062
return [worker.MaintenanceWorker()]
10631063

1064-
def _update_dnat_entry_if_needed(self, port_id):
1064+
def _update_dnat_entry_if_needed(self, port_id, up=True):
10651065
"""Update DNAT entry if using distributed floating ips."""
10661066
if not self.nb_ovn:
10671067
self.nb_ovn = self._ovn_client._nb_idl
@@ -1082,9 +1082,9 @@ def _update_dnat_entry_if_needed(self, port_id):
10821082
{ovn_const.OVN_FIP_EXT_MAC_KEY:
10831083
nat['external_mac']})).execute()
10841084

1085-
if ovn_conf.is_ovn_distributed_floating_ip():
1086-
mac = nat['external_ids'].get(ovn_const.OVN_FIP_EXT_MAC_KEY)
1087-
if mac and nat['external_mac'] != mac:
1085+
if up and ovn_conf.is_ovn_distributed_floating_ip():
1086+
mac = nat['external_ids'][ovn_const.OVN_FIP_EXT_MAC_KEY]
1087+
if nat['external_mac'] != mac:
10881088
LOG.debug("Setting external_mac of port %s to %s",
10891089
port_id, mac)
10901090
self.nb_ovn.db_set(
@@ -1152,7 +1152,7 @@ def set_port_status_down(self, port_id):
11521152
# to prevent another entity from bypassing the block with its own
11531153
# port status update.
11541154
LOG.info("OVN reports status down for port: %s", port_id)
1155-
self._update_dnat_entry_if_needed(port_id)
1155+
self._update_dnat_entry_if_needed(port_id, False)
11561156
admin_context = n_context.get_admin_context()
11571157
try:
11581158
db_port = ml2_db.get_port(admin_context, port_id)

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ def _test_set_port_status_down(self, is_compute_port=False):
11301130
resources.PORT,
11311131
provisioning_blocks.L2_AGENT_ENTITY
11321132
)
1133-
ude.assert_called_once_with(port1['port']['id'])
1133+
ude.assert_called_once_with(port1['port']['id'], False)
11341134

11351135
# If the port does NOT bellong to compute, do not notify Nova
11361136
# about it's status changes
@@ -1175,7 +1175,7 @@ def test_set_port_status_concurrent_delete(self):
11751175
side_effect=exc) as apc, \
11761176
mock.patch.object(self.mech_driver,
11771177
'_update_dnat_entry_if_needed') as ude:
1178-
self.mech_driver.set_port_status_down(port1['port']['id'])
1178+
self.mech_driver.set_port_status_down(port1['port']['id'], False)
11791179
apc.assert_called_once_with(
11801180
mock.ANY,
11811181
port1['port']['id'],
@@ -2382,40 +2382,32 @@ def test_agent_with_nb_cfg_timestamp_not_timeout(self):
23822382
self.assertTrue(agent.alive, "Agent of type %s alive=%s" % (
23832383
agent.agent_type, agent.alive))
23842384

2385-
def _test__update_dnat_entry_if_needed(self, dvr=True):
2386-
if dvr:
2387-
ovn_conf.cfg.CONF.set_override(
2388-
'enable_distributed_floating_ip', True, group='ovn')
2385+
def _test__update_dnat_entry_if_needed(self, up=True):
2386+
ovn_conf.cfg.CONF.set_override(
2387+
'enable_distributed_floating_ip', True, group='ovn')
23892388
port_id = 'fake-port-id'
23902389
fake_ext_mac_key = 'fake-ext-mac-key'
23912390
fake_nat_uuid = uuidutils.generate_uuid()
23922391
nat_row = fakes.FakeOvsdbRow.create_one_ovsdb_row(
23932392
attrs={'_uuid': fake_nat_uuid, 'external_ids': {
23942393
ovn_const.OVN_FIP_EXT_MAC_KEY: fake_ext_mac_key},
23952394
'external_mac': 'aa:aa:aa:aa:aa:aa'})
2396-
23972395
fake_db_find = mock.Mock()
23982396
fake_db_find.execute.return_value = [nat_row]
23992397
self.nb_ovn.db_find.return_value = fake_db_find
2400-
2401-
self.mech_driver._update_dnat_entry_if_needed(port_id)
2402-
2403-
if dvr:
2398+
self.mech_driver._update_dnat_entry_if_needed(port_id, up=up)
2399+
if up:
24042400
# Assert that we are setting the external_mac in the NAT table
24052401
self.nb_ovn.db_set.assert_called_once_with(
24062402
'NAT', fake_nat_uuid, ('external_mac', fake_ext_mac_key))
2407-
self.nb_ovn.db_clear.assert_not_called()
24082403
else:
2409-
self.nb_ovn.db_set.assert_not_called()
24102404
# Assert that we are cleaning the external_mac from the NAT table
24112405
self.nb_ovn.db_clear.assert_called_once_with(
24122406
'NAT', fake_nat_uuid, 'external_mac')
2413-
2414-
def test__update_dnat_entry_if_needed_dvr(self):
2407+
def test__update_dnat_entry_if_needed_up(self):
24152408
self._test__update_dnat_entry_if_needed()
2416-
2417-
def test__update_dnat_entry_if_needed_no_dvr(self):
2418-
self._test__update_dnat_entry_if_needed(dvr=False)
2409+
def test__update_dnat_entry_if_needed_down(self):
2410+
self._test__update_dnat_entry_if_needed(up=False)
24192411

24202412
@mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
24212413
'ovn_client.OVNClient._get_router_ports')

releasenotes/notes/dvr-external-mac-934409413e515eb2.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)