summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorChris Dent <cdent@anticdent.org>2018-06-05 18:07:05 -0700
committerChris Dent <cdent@anticdent.org>2018-06-08 19:28:41 +0100
commit79a1a113775df87d420b242cea4bbf953df3779c (patch)
tree5101dfb571a933d2e355217d58d9ae85f5f702bf /nova
parentc7d87f6691bbc39daca918729b769cc2d2000abd (diff)
downloadnova-79a1a113775df87d420b242cea4bbf953df3779c.tar.gz
Ensure resource class cache when listing usages
In rare circumstances it is possible to list usages in a new placement process that has not yet instantiated the _RC_CACHE but for which there are inventories and allocations in the database (added by other processes running against the same db). Before this change that would cause a 500 error (AttributeError) when the Usage objects in the UsageList were instantiated. The fix is to added _ensure_rc_cache to the two list methods. The addition is done there rather than in the _from_db_object as the latter would cause a lot of redundant checks. While we could probably devise a test for this, it's perhaps good enough to evaluate the change by inspection. If not, suggestions welcome. Change-Id: I00f7dee26f031366dbc0d3d6a03abe89afeb85fd Closes-Bug: #1775308 (cherry picked from commit 724d440122232a5bfdfec51eb0d37ca4f1d748d8)
Diffstat (limited to 'nova')
-rw-r--r--nova/objects/resource_provider.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/nova/objects/resource_provider.py b/nova/objects/resource_provider.py
index b57d0ed780..b81aa1805f 100644
--- a/nova/objects/resource_provider.py
+++ b/nova/objects/resource_provider.py
@@ -2224,11 +2224,13 @@ class UsageList(base.ObjectListBase, base.NovaObject):
@classmethod
def get_all_by_resource_provider_uuid(cls, context, rp_uuid):
+ _ensure_rc_cache(context)
usage_list = cls._get_all_by_resource_provider_uuid(context, rp_uuid)
return base.obj_make_list(context, cls(context), Usage, usage_list)
@classmethod
def get_all_by_project_user(cls, context, project_id, user_id=None):
+ _ensure_rc_cache(context)
usage_list = cls._get_all_by_project_user(context, project_id,
user_id=user_id)
return base.obj_make_list(context, cls(context), Usage, usage_list)