From 1a440dd61b04b37d0e2a9434e802f5a1ee3c198b Mon Sep 17 00:00:00 2001 From: kyu0 Date: Thu, 13 Jun 2024 12:46:54 +0900 Subject: [PATCH] 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 --- neutron/db/securitygroups_db.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/neutron/db/securitygroups_db.py b/neutron/db/securitygroups_db.py index 4f2c1377bc5..28aa36707bf 100644 --- a/neutron/db/securitygroups_db.py +++ b/neutron/db/securitygroups_db.py @@ -109,8 +109,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)