Browse Source

Fix error in router port maintenance code

When a port needs to be created or updated on OVN side by the
maintenance task we need to recover the router ID from the
port, which is on the device_id field.
At some point in time during development it got changed to
device_owner, which is a logical name referring to the type
of owner: compute, router, dhcp, etc...)

Also, when getting the lrouter port from the NBDB we were
using a uuid, while we needed to convert uuid to lrp port
name.

Those mistakes was causing the maintenance code uncapable of
recovering router ports that were detected as outdated, or
not created on the OVN side.

Change-Id: Iea8060b11cc4076e6efc300dd9079ddafcc3fb5e
Closes-Bug: 1746979
changes/91/540391/5
Miguel Angel Ajo 4 years ago
parent
commit
251aabd857
  1. 10
      networking_ovn/common/maintenance.py
  2. 2
      networking_ovn/ovsdb/impl_idl_ovn.py
  3. 8
      networking_ovn/tests/unit/common/test_maintenance.py

10
networking_ovn/common/maintenance.py

@ -138,7 +138,7 @@ class DBInconsistenciesPeriodics(object):
self._ovn_client._plugin.get_port,
'ovn_get': self._nb_idl.get_lrouter_port,
'ovn_create': self._create_lrouter_port,
'ovn_update': self._update_lrouter_port,
'ovn_update': self._ovn_client.update_router_port,
'ovn_delete': self._ovn_client.delete_router_port,
},
}
@ -249,10 +249,6 @@ class DBInconsistenciesPeriodics(object):
def _create_lrouter_port(self, port):
admin_context = n_context.get_admin_context()
router_id = port['device_id']
self._ovn_client._l3_plugin.add_router_interface(
admin_context, port['device_owner'],
{'port_id': port['id']})
def _update_lrouter_port(self, port):
self._ovn_client._l3_plugin.update_router_port(
port['device_owner'], port)
admin_context, router_id, {'port_id': port['id']})

2
networking_ovn/ovsdb/impl_idl_ovn.py

@ -638,6 +638,8 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
def get_lrouter_port(self, lrp_name):
# TODO(mangelajo): Implement lrp_get() ovsdbapp and use from here
if uuidutils.is_uuid_like(lrp_name):
lrp_name = utils.ovn_lrouter_port_name(lrp_name)
lrp = self.db_find_rows('Logical_Router_Port', ('name', '=', lrp_name))
result = lrp.execute(check_error=True)
return result[0] if result else None

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

@ -167,3 +167,11 @@ class TestDBInconsistenciesPeriodics(db_base.DBTestCase,
def test_fix_security_group_create_version_mismatch(self):
self._test_fix_security_group_create(revision_number=2)
def test__create_lrouter_port(self):
port = {'id': 'port-id',
'device_id': 'router-id'}
self.periodic._create_lrouter_port(port)
l3_mock = self.periodic._ovn_client._l3_plugin
l3_mock.add_router_interface.assert_called_once_with(
mock.ANY, port['device_id'], {'port_id': port['id']})

Loading…
Cancel
Save