Fix maintenance LRP prefix adding fails over 'name' attribute missing

Error of 'dict' object has no attribute 'name' noticed, suspected due to
wrong use of object property access instead of the needed dict mapping
lookup (probably confusion between using `db_find` and `db_find_rows`).

Closes-Bug: #2134338
Change-Id: I1d4a8cc03c99274733eba30dd06893eb38ebc138
Signed-off-by: Maor Blaustein <mblue@redhat.com>
This commit is contained in:
Maor Blaustein
2025-12-07 16:52:13 +02:00
parent 4d2c562d22
commit a991dd1d6b
2 changed files with 5 additions and 7 deletions

View File

@@ -521,7 +521,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
router_id = port['external_ids'].get(
ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY)
txn.add(self._nb_idl.update_lrouter_port(
name=port.name,
name=port['name'],
external_ids=self._ovn_client._gen_router_port_ext_ids(
port, router_id)))
self._sync_timer.stop()

View File

@@ -395,19 +395,17 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
self.assertFalse(mock_log.called)
def test_update_lrouter_ports_ext_ids_name_prefix(self):
lrp1_no_prefix = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={
lrp1_no_prefix = {
'_uuid': 'port-id1',
'name': 'lrp-id1',
'external_ids': {
constants.OVN_ROUTER_NAME_EXT_ID_KEY: 'rtr-id1'}})
lrp2_with_prefix = fakes.FakeOvsdbRow.create_one_ovsdb_row(
attrs={
constants.OVN_ROUTER_NAME_EXT_ID_KEY: 'rtr-id1'}}
lrp2_with_prefix = {
'_uuid': 'port-id2',
'name': 'lrp-id2',
'external_ids': {
constants.OVN_ROUTER_NAME_EXT_ID_KEY:
'%srtr-id2' % constants.OVN_NAME_PREFIX}})
'%srtr-id2' % constants.OVN_NAME_PREFIX}}
nb_idl = self.fake_ovn_client._nb_idl
nb_idl.db_find.return_value.execute.return_value = [