File tree Expand file tree Collapse file tree
tests/unit/plugins/ml2/drivers/ovn/mech_driver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -296,15 +296,23 @@ def update_acls_for_security_group(plugin,
296296 if not is_sg_enabled ():
297297 return
298298
299+ # It's possible to have a security group created on one controller and
300+ # then a security group rule created on a different controller quickly
301+ # enough that the second controller does not yet see that security group
302+ # in its local cache of the OVN northbound database. Check if the port
303+ # group is present or not in the idl's local copy of the database before
304+ # creating the security group rule.
305+ pg_name = utils .ovn_port_group_name (security_group_id )
306+ ovn .check_for_row_by_value_and_retry ('Port_Group' , 'name' , pg_name )
307+
299308 # Check if ACL log name and severity supported or not
300309 keep_name_severity = _acl_columns_name_severity_supported (ovn )
301310
302311 sg = plugin .get_security_group (admin_context , security_group_id )
303312 stateful = is_sg_stateful (sg )
304313
305314 acl = _add_sg_rule_acl_for_port_group (
306- utils .ovn_port_group_name (security_group_id ),
307- stateful , security_group_rule )
315+ pg_name , stateful , security_group_rule )
308316 # Remove ACL log name and severity if not supported
309317 if is_add_acl :
310318 if not keep_name_severity :
Original file line number Diff line number Diff line change @@ -4522,6 +4522,15 @@ def test_update_sg_change_rule(self):
45224522 sg_r = self ._create_sg_rule (sg ['id' ], 'ingress' ,
45234523 const .PROTO_NAME_UDP ,
45244524 ethertype = const .IPv6 )
4525+
4526+ # Updating an ACL will call 'check_for_row_by_value_and_retry'
4527+ # for the PG at least once.
4528+ pg_name = ovn_utils .ovn_port_group_name (sg ['id' ])
4529+ cfrbvar = self .mech_driver .nb_ovn .check_for_row_by_value_and_retry
4530+ cfrbvar .assert_has_calls ([
4531+ mock .call ('Port_Group' , 'name' , pg_name )
4532+ ])
4533+
45254534 self .assertEqual (
45264535 1 , self .mech_driver .nb_ovn .pg_acl_add .call_count )
45274536
You can’t perform that action at this time.
0 commit comments