Modify the default SG rule count logic when creating SG

During the creation of SG, not to exceed the SG rule quota, the number
of default SG rules that will be automatically created must be counted.
It is always 2 (in case of the default SG, it is 4), but it is wrong
since it depends on the default SG rules.

Closes-Bug: #2067239
Change-Id: Ic86826b71c1160a6891f09ca1e40135049a8948a
(cherry picked from commit 1a440dd61b)
This commit is contained in:
kyu0 2024-06-13 12:46:54 +09:00 committed by Rodolfo Alonso Hernandez
parent 32ef705e5b
commit e8ac162720

View File

@ -110,8 +110,12 @@ class SecurityGroupDbMixin(
return self.get_security_group(context, existing_def_sg_id)
with db_api.CONTEXT_WRITER.using(context):
delta = len(ext_sg.sg_supported_ethertypes)
delta = delta * 2 if default_sg else delta
if default_sg:
delta = sg_default_rules_obj.SecurityGroupDefaultRule.count(
context, used_in_default_sg=True)
else:
delta = sg_default_rules_obj.SecurityGroupDefaultRule.count(
context, used_in_non_default_sg=True)
quota.QUOTAS.quota_limit_check(context, tenant_id,
security_group_rule=delta)