Don't rely on SQLAlchemy collections magically initializing __dict__

The behavior of accessing "foo.some_collection" mutating __dict__ is going
away.   You still get an empty list back but the assumptions made
in Nova here go beyond that including that security group tests
are expecting "rules=[]" to be in `__dict__` which will not be the case.
Set an empty list explicitly here.

Related SQLAlchemy gerrit: https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1283/
Oslo.db discussion: https://bugs.launchpad.net/oslo.db/+bug/1830504

Change-Id: I986e069a65b608799b5074829fa796c6c4b98da8
This commit is contained in:
Mike Bayer 2019-05-25 19:27:56 -04:00
parent 37ccd7ec3a
commit c66a03bae7
1 changed files with 1 additions and 1 deletions

View File

@ -3861,7 +3861,7 @@ def security_group_create(context, values):
security_group_ref = models.SecurityGroup()
# FIXME(devcamcar): Unless I do this, rules fails with lazy load exception
# once save() is called. This will get cleaned up in next orm pass.
security_group_ref.rules
security_group_ref.rules = []
security_group_ref.update(values)
try:
with get_context_manager(context).writer.savepoint.using(context):