ovn_idl_impl: fix a logic bug in get_sg_port_groups

The function is supposed to omit neutron_pg_drop Port_Group (as per its
docstring) but it actually returns it because of incorrect if-statement
structure.

The function is not used anywhere in the tree and hence doesn't affect
any feature, at least in master.

(It was used before I27af495f96a3ea88dd31345dbfb55f1be8faabd6.)

The function will be used in a consequent patch, so it now becomes
important to make it behave as documented.

Related-Bug: #2009053
Change-Id: I0c5d3db521131cc71135a9c787ed01479b451cfb
This commit is contained in:
Ihar Hrachyshka 2023-03-07 03:07:02 +00:00
parent d9358b67bd
commit d44f164f4d
2 changed files with 3 additions and 3 deletions

View File

@ -803,7 +803,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
port_groups = {}
for row in self._tables['Port_Group'].rows.values():
name = getattr(row, 'name')
if not (ovn_const.OVN_SG_EXT_ID_KEY in row.external_ids or
if (ovn_const.OVN_SG_EXT_ID_KEY not in row.external_ids or
name == ovn_const.OVN_DROP_PORT_GROUP_NAME):
continue
data = {}

View File

@ -1474,7 +1474,6 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
db_pgs = []
for sg in self._list('security-groups')['security_groups']:
db_pgs.append(utils.ovn_port_group_name(sg['id']))
db_pgs.append(ovn_const.OVN_DROP_PORT_GROUP_NAME)
nb_pgs = _plugin_nb_ovn.get_sg_port_groups()
@ -1484,7 +1483,8 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
if should_match:
self.assertCountEqual(nb_pgs, db_pgs)
self.assertCountEqual(mn_pgs, db_pgs)
# pg_drop port group doesn't have corresponding neutron sg
self.assertEqual(len(mn_pgs), len(db_pgs) + 1)
else:
self.assertRaises(AssertionError, self.assertCountEqual,
nb_pgs, db_pgs)