Browse Source

Merge "[OVN] Tune OVN routers to reduce the mem footprint for ML2/OVN" into stable/train

changes/04/812304/7
Zuul 7 months ago committed by Gerrit Code Review
parent
commit
e9af17739e
  1. 26
      networking_ovn/common/maintenance.py
  2. 4
      networking_ovn/common/ovn_client.py
  3. 28
      networking_ovn/tests/unit/common/test_maintenance.py
  4. 3
      networking_ovn/tests/unit/l3/test_l3_ovn.py

26
networking_ovn/common/maintenance.py

@ -14,6 +14,7 @@
# under the License.
import abc
import copy
import inspect
import threading
@ -676,6 +677,31 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
raise periodics.NeverAgain()
# TODO(lucasagomes): Remove this in the Z cycle
# A static spacing value is used here, but this method will only run
# once per lock due to the use of periodics.NeverAgain().
@periodics.periodic(spacing=600, run_immediately=True)
def check_router_mac_binding_options(self):
if not self.has_lock:
return
cmds = []
for router in self._nb_idl.lr_list().execute(check_error=True):
if (router.options.get('always_learn_from_arp_request') and
router.options.get('dynamic_neigh_routers')):
continue
opts = copy.deepcopy(router.options)
opts.update({'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'})
cmds.append(self._nb_idl.update_lrouter(router.name, options=opts))
if cmds:
with self._nb_idl.transaction(check_error=True) as txn:
for cmd in cmds:
txn.add(cmd)
raise periodics.NeverAgain()
class HashRingHealthCheckPeriodics(object):

4
networking_ovn/common/ovn_client.py

@ -1183,11 +1183,13 @@ class OVNClient(object):
enabled = router.get('admin_state_up')
lrouter_name = utils.ovn_name(router['id'])
added_gw_port = None
options = {'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'}
with self._nb_idl.transaction(check_error=True) as txn:
txn.add(self._nb_idl.create_lrouter(lrouter_name,
external_ids=external_ids,
enabled=enabled,
options={}))
options=options))
# TODO(lucasagomes): add_external_gateway is being only used
# by the ovn_db_sync.py script, remove it after the database
# synchronization work

28
networking_ovn/tests/unit/common/test_maintenance.py

@ -432,3 +432,31 @@ class TestDBInconsistenciesPeriodics(db_base.DBTestCase,
mock.call('lsp5', mcast_flood_reports='true', mcast_flood='false')]
nb_idl.lsp_set_options.assert_has_calls(expected_calls)
def test_check_router_mac_binding_options(self):
nb_idl = self.fake_ovn_client._nb_idl
lr0 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={'name': 'lr0',
'options': {'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'}})
lr1 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={'name': 'lr1', 'options': {}})
lr2 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={'name': 'lr2', 'options': {}})
nb_idl.lr_list.return_value.execute.return_value = [lr0, lr1, lr2]
# Invoke the periodic method, it meant to run only once at startup
# so NeverAgain will be raised at the end
self.assertRaises(periodics.NeverAgain,
self.periodic.check_router_mac_binding_options)
# Assert lr1 and lr2 had their options updated since the values
# were not set
expected_calls = [
mock.call('lr1',
options={'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'}),
mock.call('lr2',
options={'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'})]
nb_idl.update_lrouter.assert_has_calls(expected_calls)

3
networking_ovn/tests/unit/l3/test_l3_ovn.py

@ -488,7 +488,8 @@ class OVNL3RouterPlugin(test_mech_driver.OVNMechanismDriverTestCase):
ovn_const.OVN_ROUTER_AZ_HINTS_EXT_ID_KEY: ''}
self.l3_inst._ovn.create_lrouter.assert_called_once_with(
'neutron-router-id', external_ids=external_ids,
enabled=True, options={})
enabled=True, options={'always_learn_from_arp_request': 'false',
'dynamic_neigh_routers': 'true'})
self.l3_inst._ovn.add_lrouter_port.assert_called_once_with(
**self.fake_ext_gw_port_assert)
expected_calls = [

Loading…
Cancel
Save