[OVN] Skip ports with VNIC type direct and no port binding

In the method ``add_vnic_type_and_pb_capabilities_to_lsp``, if the port
binding profile is an empty string (or something that cannot be parsed
by jsonutils), skip this port.

Closes-Bug: #2006112
Change-Id: Ifa8956bf1c5eb9b6c3214638ac4e5b7f10e4cf74
This commit is contained in:
Rodolfo Alonso Hernandez 2023-02-03 20:19:38 +01:00
parent 8e2e8ce72d
commit 76f3b75ad6
2 changed files with 8 additions and 2 deletions

View File

@ -938,7 +938,11 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
n_context.get_admin_context(), portbindings.VNIC_DIRECT)
with self._nb_idl.transaction(check_error=True) as txn:
for pb in port_bindings:
profile = jsonutils.loads(pb.profile)
try:
profile = jsonutils.loads(pb.profile)
except ValueError:
continue
capabilities = profile.get(ovn_const.PORT_CAP_PARAM, [])
external_ids = {
ovn_const.OVN_PORT_VNIC_TYPE_KEY: portbindings.VNIC_DIRECT,

View File

@ -841,7 +841,8 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
profile = {'capabilities': ['switchdev']}
pb1 = mock.Mock(profile=jsonutils.dumps(profile), port_id='port1')
pb2 = mock.Mock(profile=jsonutils.dumps(profile), port_id='port2')
mock_get_pb.return_value = [pb1, pb2]
pb3 = mock.Mock(profile='', port_id='port3')
mock_get_pb.return_value = [pb1, pb2, pb3]
self.assertRaises(
periodics.NeverAgain,
@ -854,3 +855,4 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
mock.call(lport_name='port2', if_exists=True,
external_ids=external_ids)]
nb_idl.set_lswitch_port.assert_has_calls(expected_calls)
self.assertEqual(2, nb_idl.set_lswitch_port.call_count)