[AIM] Don't override loading of SG rules when validating

Previously, the query for security groups during validation overrode
the loading of the rules from subquery to joined to minimize the
number of round-trips to the DB. Upstream neutron, in
https://review.opendev.org/#/c/660174/, changed the default loading
from subquery to dynamic. This has been back-ported through queens,
and breaks our override, so the override is replaced with a REVISIT.

Change-Id: I7353994dcb0690f1e8adb243b1020ddf1f1b461a
This commit is contained in:
Robert Kukura 2019-05-31 08:17:35 -04:00
parent 3f6d73958a
commit 94dfa082ca
1 changed files with 6 additions and 2 deletions

View File

@ -5248,10 +5248,14 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
for sg_id, ip in query(mgr.actual_session):
sg_ips[sg_id].add(ip)
# REVISIT: Loading of the SG rules was previously optimized
# via options(orm.joinedload('rules')), but this broke when
# upstream neutron changed the relationship from
# lazy='subquery' to lazy='dynamic'. If there is any way to
# override this dynamic loading with eager loading for a
# specific query, we may want to do so.
query = BAKERY(lambda s: s.query(
sg_models.SecurityGroup))
query += lambda q: q.options(
orm.joinedload('rules'))
for sg_db in query(mgr.actual_session):
# Ignore anonymous SGs, which seem to be a Neutron bug.
if sg_db.tenant_id: