Skip to content

Commit b9067eb

Browse files
committed
Revert: Revert: Ensure traffic is not centralized if DVR is enabled
1 parent d4e1df3 commit b9067eb

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
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
@@ -1048,7 +1048,7 @@ def get_workers(self):
10481048
# See doc/source/design/ovn_worker.rst for more details.
10491049
return [worker.MaintenanceWorker()]
10501050

1051-
def _update_dnat_entry_if_needed(self, port_id, up=True):
1051+
def _update_dnat_entry_if_needed(self, port_id):
10521052
"""Update DNAT entry if using distributed floating ips."""
10531053
if not self.nb_ovn:
10541054
self.nb_ovn = self._ovn_client._nb_idl
@@ -1069,9 +1069,9 @@ def _update_dnat_entry_if_needed(self, port_id, up=True):
10691069
{ovn_const.OVN_FIP_EXT_MAC_KEY:
10701070
nat['external_mac']})).execute()
10711071

1072-
if up and ovn_conf.is_ovn_distributed_floating_ip():
1073-
mac = nat['external_ids'][ovn_const.OVN_FIP_EXT_MAC_KEY]
1074-
if nat['external_mac'] != mac:
1072+
if ovn_conf.is_ovn_distributed_floating_ip():
1073+
mac = nat['external_ids'].get(ovn_const.OVN_FIP_EXT_MAC_KEY)
1074+
if mac and nat['external_mac'] != mac:
10751075
LOG.debug("Setting external_mac of port %s to %s",
10761076
port_id, mac)
10771077
self.nb_ovn.db_set(
@@ -1139,7 +1139,7 @@ def set_port_status_down(self, port_id):
11391139
# to prevent another entity from bypassing the block with its own
11401140
# port status update.
11411141
LOG.info("OVN reports status down for port: %s", port_id)
1142-
self._update_dnat_entry_if_needed(port_id, False)
1142+
self._update_dnat_entry_if_needed(port_id)
11431143
admin_context = n_context.get_admin_context()
11441144
try:
11451145
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: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ def _test_set_port_status_down(self, is_compute_port=False):
11121112
resources.PORT,
11131113
provisioning_blocks.L2_AGENT_ENTITY
11141114
)
1115-
ude.assert_called_once_with(port1['port']['id'], False)
1115+
ude.assert_called_once_with(port1['port']['id'])
11161116

11171117
# If the port does NOT bellong to compute, do not notify Nova
11181118
# about it's status changes
@@ -1157,7 +1157,7 @@ def test_set_port_status_concurrent_delete(self):
11571157
side_effect=exc) as apc, \
11581158
mock.patch.object(self.mech_driver,
11591159
'_update_dnat_entry_if_needed') as ude:
1160-
self.mech_driver.set_port_status_down(port1['port']['id'], False)
1160+
self.mech_driver.set_port_status_down(port1['port']['id'])
11611161
apc.assert_called_once_with(
11621162
mock.ANY,
11631163
port1['port']['id'],
@@ -2358,32 +2358,40 @@ def test_agent_with_nb_cfg_timestamp_not_timeout(self):
23582358
self.assertTrue(agent.alive, "Agent of type %s alive=%s" % (
23592359
agent.agent_type, agent.alive))
23602360

2361-
def _test__update_dnat_entry_if_needed(self, up=True):
2362-
ovn_conf.cfg.CONF.set_override(
2363-
'enable_distributed_floating_ip', True, group='ovn')
2361+
def _test__update_dnat_entry_if_needed(self, dvr=True):
2362+
if dvr:
2363+
ovn_conf.cfg.CONF.set_override(
2364+
'enable_distributed_floating_ip', True, group='ovn')
23642365
port_id = 'fake-port-id'
23652366
fake_ext_mac_key = 'fake-ext-mac-key'
23662367
fake_nat_uuid = uuidutils.generate_uuid()
23672368
nat_row = fakes.FakeOvsdbRow.create_one_ovsdb_row(
23682369
attrs={'_uuid': fake_nat_uuid, 'external_ids': {
23692370
ovn_const.OVN_FIP_EXT_MAC_KEY: fake_ext_mac_key},
23702371
'external_mac': 'aa:aa:aa:aa:aa:aa'})
2372+
23712373
fake_db_find = mock.Mock()
23722374
fake_db_find.execute.return_value = [nat_row]
23732375
self.nb_ovn.db_find.return_value = fake_db_find
2374-
self.mech_driver._update_dnat_entry_if_needed(port_id, up=up)
2375-
if up:
2376+
2377+
self.mech_driver._update_dnat_entry_if_needed(port_id)
2378+
2379+
if dvr:
23762380
# Assert that we are setting the external_mac in the NAT table
23772381
self.nb_ovn.db_set.assert_called_once_with(
23782382
'NAT', fake_nat_uuid, ('external_mac', fake_ext_mac_key))
2383+
self.nb_ovn.db_clear.assert_not_called()
23792384
else:
2385+
self.nb_ovn.db_set.assert_not_called()
23802386
# Assert that we are cleaning the external_mac from the NAT table
23812387
self.nb_ovn.db_clear.assert_called_once_with(
23822388
'NAT', fake_nat_uuid, 'external_mac')
2383-
def test__update_dnat_entry_if_needed_up(self):
2389+
2390+
def test__update_dnat_entry_if_needed_dvr(self):
23842391
self._test__update_dnat_entry_if_needed()
2385-
def test__update_dnat_entry_if_needed_down(self):
2386-
self._test__update_dnat_entry_if_needed(up=False)
2392+
2393+
def test__update_dnat_entry_if_needed_no_dvr(self):
2394+
self._test__update_dnat_entry_if_needed(dvr=False)
23872395

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

0 commit comments

Comments
 (0)