From e8ac16272021c7cee594f35c1b786d20984e7826 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 (cherry picked from commit 1a440dd61b04b37d0e2a9434e802f5a1ee3c198b) --- 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 fd21f981605..eed101ee2ea 100644 --- a/neutron/db/securitygroups_db.py +++ b/neutron/db/securitygroups_db.py @@ -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)