From 586727cef755abeb3360f176782c1b1dd680d318 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Dulko?= Date: Fri, 20 Nov 2015 12:36:22 +0100 Subject: [PATCH] Eager load columns in volume_get_active_by_window All other volume-related methods in db.sqlalchemy.api are eager loading volume_metadata, volume_admin_metadata (if admin), volume_type, volume_attachment and consistencygroup. volume_get_active_by_window wasn't, causing fails because of SQLAlchemy Session being closed when trying to lazy load volume_metadata. This commit adds missing options(joinedload()) to this query. Change-Id: I33ec89d7f1f43aae6010aaa6e12951b7c522b8f0 Closes-Bug: 1517763 Related-Bug: 1501838 --- cinder/db/sqlalchemy/api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index b3869e0ae..3830df616 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -2769,6 +2769,14 @@ def volume_get_active_by_window(context, if project_id: query = query.filter_by(project_id=project_id) + query = (query.options(joinedload('volume_metadata')). + options(joinedload('volume_type')). + options(joinedload('volume_attachment')). + options(joinedload('consistencygroup'))) + + if is_admin_context(context): + query = query.options(joinedload('volume_admin_metadata')) + return query.all() -- 2.45.2