From c66a03bae73e7acd236049ec455b2efe28d25833 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 25 May 2019 19:27:56 -0400 Subject: [PATCH] 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 --- nova/db/sqlalchemy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index ea4b7d6884c2..3fd0dcc792af 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -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):