diff options
author | Zane Bitter <zbitter@redhat.com> | 2017-11-20 13:59:19 -0500 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2017-11-20 14:29:38 -0500 |
commit | dbc852b47a9a6a1044dd2a554f16f27681dbe762 (patch) | |
tree | 98fdf106503067005b8c4d0b93816a1e07631256 /heat/objects | |
parent | 38f1975cf71bf1f4c006c1009c308aaedd58a923 (diff) | |
download | heat-dbc852b47a9a6a1044dd2a554f16f27681dbe762.tar.gz |
Eager-load properties for nested resource list
When doing "openstack stack resource list --nested-depth=n", we were
lazy-loading the resources' properties data. This is expensive, especially
when there are a large number of resources. Eager-load the data, as we
always use it to show the resources.
For consistency, always eager-load the resource 'data' (even in
resource_get), because the Resource versioned object accesses it
unconditionally.
Change-Id: Idb871fddf77bf24828878c315e19e200c28841be
Related-Bug: #1665503
Diffstat (limited to 'heat/objects')
-rw-r--r-- | heat/objects/event.py | 2 | ||||
-rw-r--r-- | heat/objects/resource.py | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/heat/objects/event.py b/heat/objects/event.py index 6c53c68d2..eb4f7587c 100644 --- a/heat/objects/event.py +++ b/heat/objects/event.py @@ -79,7 +79,7 @@ class Event( @property def resource_properties(self): if self._resource_properties is None: - LOG.info('rsrp_prop_data lazy load') + LOG.info('rsrc_prop_data lazy load') rpd_obj = rpd.ResourcePropertiesData.get_by_id( self._context, self.rsrc_prop_data_id) self._resource_properties = rpd_obj.data or {} diff --git a/heat/objects/resource.py b/heat/objects/resource.py index 67cc24a0c..2e3e6c31f 100644 --- a/heat/objects/resource.py +++ b/heat/objects/resource.py @@ -164,7 +164,7 @@ class Resource( def properties_data(self): if (not self._properties_data and self.rsrc_prop_data_id is not None): - LOG.info('rsrp_prop_data lazy load') + LOG.info('rsrc_prop_data lazy load') rpd_obj = rpd.ResourcePropertiesData.get_by_id( self._context, self.rsrc_prop_data_id) self._properties_data = rpd_obj.data or {} @@ -264,11 +264,13 @@ class Resource( return dict(resources) @classmethod - def get_all_by_root_stack(cls, context, stack_id, filters, cache=False): + def get_all_by_root_stack(cls, context, stack_id, filters, cache=False, + eager=True): resources_db = db_api.resource_get_all_by_root_stack( context, stack_id, - filters) + filters, + eager=eager) all = cls._resources_to_dict(context, resources_db) if cache: context.cache(ResourceCache).set_by_stack_id(all) |