Convergence: Refactor convergence dependency

A new property is added to fetch convergence dependencies from the
stack.

Change-Id: If2eb29f9222f21390513fad5702dc4718d5c4165
changes/84/203484/8
Anant Patil 7 years ago committed by Sirushti Murugesan
parent d23ebb6065
commit cd3931c635
  1. 32
      heat/engine/stack.py
  2. 10
      heat/engine/worker.py

@ -144,6 +144,7 @@ class Stack(collections.Mapping):
self.current_deps = current_deps
self.cache_data = cache_data
self._worker_client = None
self._convg_deps = None
if use_stored_context:
self.context = self.stored_context()
@ -971,8 +972,13 @@ class Stack(collections.Mapping):
def _converge_create_or_update(self):
self._update_or_store_resources()
self.convergence_dependencies = self._convergence_dependencies(
self.ext_rsrcs_db, self.dependencies)
self._compute_convg_dependencies(self.ext_rsrcs_db, self.dependencies)
# Store list of edges
self.current_deps = {
'edges': [[rqr, rqd] for rqr, rqd in
self.convergence_dependencies.graph().edges()]}
self.store()
LOG.info(_LI('convergence_dependencies: %s'),
self.convergence_dependencies)
@ -985,12 +991,6 @@ class Stack(collections.Mapping):
sync_point.create(
self.context, self.id, self.current_traversal, True, self.id)
# Store list of edges
self.current_deps = {
'edges': [[rqr, rqd] for rqr, rqd in
self.convergence_dependencies.graph().edges()]}
self.store()
leaves = set(self.convergence_dependencies.leaves())
if not any(leaves):
self.mark_complete(self.current_traversal)
@ -1070,8 +1070,8 @@ class Stack(collections.Mapping):
)
rsrcs[existing_rsrc_db.name] = existing_rsrc_db
def _convergence_dependencies(self, existing_resources,
curr_template_dep):
def _compute_convg_dependencies(self, existing_resources,
curr_template_dep):
dep = curr_template_dep.translate(lambda res: (res.id, True))
if existing_resources:
for rsrc_id, rsrc in existing_resources.items():
@ -1085,7 +1085,17 @@ class Stack(collections.Mapping):
if (rsrc.id, True) in dep:
dep += (rsrc_id, False), (rsrc_id, True)
return dep
self._convg_deps = dep
@property
def convergence_dependencies(self):
if self._convg_deps is None:
current_deps = ([tuple(i), (tuple(j) if j is not None else None)]
for i, j in self.current_deps['edges'])
self._convg_deps = dependencies.Dependencies(edges=current_deps)
return self._convg_deps
@scheduler.wrappertask
def update_task(self, newstack, action=UPDATE, event=None):

@ -24,7 +24,6 @@ from heat.common import exception
from heat.common.i18n import _LE
from heat.common.i18n import _LI
from heat.common import messaging as rpc_messaging
from heat.engine import dependencies
from heat.engine import resource
from heat.engine import stack as parser
from heat.engine import sync_point
@ -180,14 +179,9 @@ class WorkerService(service.Service):
return False
def _compute_dependencies(self, stack):
current_deps = ([tuple(i), (tuple(j) if j is not None else None)]
for i, j in stack.current_deps['edges'])
return dependencies.Dependencies(edges=current_deps)
def _retrigger_check_resource(self, cnxt, is_update, resource_id, stack):
current_traversal = stack.current_traversal
graph = self._compute_dependencies(stack).graph()
graph = stack.convergence_dependencies.graph()
key = (resource_id, is_update)
predecessors = graph[key]
@ -204,7 +198,7 @@ class WorkerService(service.Service):
def _initiate_propagate_resource(self, cnxt, resource_id,
current_traversal, is_update, rsrc,
stack):
deps = self._compute_dependencies(stack)
deps = stack.convergence_dependencies
graph = deps.graph()
graph_key = (resource_id, is_update)

Loading…
Cancel
Save