Speed up show-stack with outputs in legacy path

When we show a stack including the outputs, we calculate all of the
resource attributes that are referenced anywhere in the stack. In
convergence, these are either already cached (and therefore fast) or need
to be cached (and therefore the initial slowness will pay off in future).
This isn't the case in the legacy path though, since we are not doing
caching of attributes in the database in that path. So this is
unnecessarily calculating all of the referenced attribute values, which are
potentially very slow to get.

For legacy stacks, only calculate the attribute values needed to show the
outputs.

Change-Id: I35800c7f87b58daf05cbabd05bcbcd75d0c0fadb
Partial-Bug: #1719333
This commit is contained in:
Zane Bitter 2017-09-25 10:53:38 -04:00
parent 4ff8bd7882
commit 49d833f9ac
1 changed files with 4 additions and 2 deletions

View File

@ -530,7 +530,9 @@ class EngineService(service.ServiceBase):
def show(stack):
if resolve_outputs:
for res in stack._explicit_dependencies():
node_data = res.node_data(for_outputs=True)
ensure_cache = stack.convergence and res.id is not None
node_data = res.node_data(for_resources=ensure_cache,
for_outputs=True)
stk_defn.update_resource_data(stack.defn, res.name,
node_data)
@ -541,7 +543,7 @@ class EngineService(service.ServiceBase):
# * Near simultaneous updates (say by an update and a
# signal)
# * The first time resolving a pre-Pike stack
if stack.convergence and res.id is not None:
if ensure_cache:
res.store_attributes()
return api.format_stack(stack, resolve_outputs=resolve_outputs)