Efficient passing of attrs during traversals

Two improvements:

Do not iterate through stack outputs when determining what attributes
to send as input_data to the next resources in a traversal; it is at
best extra processing and at worse results in extra attributes being
included in input_data.

Do not re-resolve attributes / re-calculate input_data when we already
have it. I.e., when a resource constructs input_data to send to a
requirer resource, that same input_data may be used for all other
requirer resources.

Change-Id: I64089fb0774c10f172d986c3f87090e91cb3f263
Closes-Bug: #1656125
This commit is contained in:
Crag Wolfe
2017-01-10 16:12:54 -08:00
parent 4507322675
commit efabef60d0
3 changed files with 25 additions and 33 deletions

View File

@@ -462,17 +462,14 @@ class Stack(collections.Mapping):
LOG.warning(_LW("Unable to set parameters StackId identifier"))
@staticmethod
def get_dep_attrs(resources, outputs, resource_name, value_sec):
def get_dep_attrs(resources, resource_name):
"""Return the attributes of the specified resource that are referenced.
Return an iterator over any attributes of the specified resource that
are referenced.
are referenced in resources.
"""
attr_lists = itertools.chain((res.dep_attrs(resource_name)
for res in resources),
(out.dep_attrs(resource_name)
for out in six.itervalues(outputs)))
return set(itertools.chain.from_iterable(attr_lists))
return set(itertools.chain.from_iterable(
res.dep_attrs(resource_name) for res in resources))
def _get_dependencies(self, ignore_errors=True):
"""Return the dependency graph for a list of resources."""