Skip to content

Commit 69f64a1

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Change SG rules backref load method to "joined"" into stable/2023.1
2 parents 2af9b5c + 3dec91e commit 69f64a1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

neutron/db/models/securitygroup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ class SecurityGroupRule(standard_attr.HasStandardAttributes, model_base.BASEV2,
101101
port_range_min = sa.Column(sa.Integer)
102102
port_range_max = sa.Column(sa.Integer)
103103
remote_ip_prefix = sa.Column(sa.String(255))
104+
# NOTE(ralonsoh): loading method is temporarily changed to "joined" until
105+
# a proper way to only load the security groups "shared" field, without
106+
# loading the rest of the synthetic fields, is implemented. LP#2052419
107+
# description for more information and context.
104108
security_group = orm.relationship(
105109
SecurityGroup, load_on_pending=True,
106-
backref=orm.backref('rules', cascade='all,delete', lazy='dynamic'),
110+
backref=orm.backref('rules', cascade='all,delete', lazy='joined'),
107111
primaryjoin="SecurityGroup.id==SecurityGroupRule.security_group_id")
108112
source_group = orm.relationship(
109113
SecurityGroup,

neutron/tests/unit/db/test_securitygroups_db.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ def _test_security_group_precommit_create_event(self,
347347
# Especially we want to check the revision number here.
348348
sg_dict_got = self.mixin.get_security_group(
349349
self.ctx, sg_dict['id'])
350+
# Order the SG rules to avoid issues in the assertion.
351+
for _sg_dict in (sg_dict, sg_dict_got):
352+
_sg_dict['security_group_rules'] = sorted(
353+
_sg_dict['security_group_rules'], key=lambda d: d['id'])
350354
self.assertEqual(sg_dict, sg_dict_got)
351355

352356
def test_security_group_precommit_create_event_with_revisions(self):

0 commit comments

Comments
 (0)