From 9994950f40aff4f86c0df8c5d11fbf1a66d2c673 Mon Sep 17 00:00:00 2001 From: Rakesh H S Date: Tue, 5 May 2015 14:22:02 +0530 Subject: [PATCH] fix for retrieving leaf nodes in convergence stack delete When generating the dependencies, the deletion order is already taken care, hence we need not reverse the graph. Change-Id: Iff158443f2281a07e3a136a4cf6f77f7be592d3f --- heat/engine/dependencies.py | 14 +++++++------- heat/engine/stack.py | 6 +----- heat/tests/test_dependencies.py | 4 ++-- heat/tests/test_engine_service.py | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/heat/engine/dependencies.py b/heat/engine/dependencies.py index c39be1e8fd..0b7f394398 100644 --- a/heat/engine/dependencies.py +++ b/heat/engine/dependencies.py @@ -158,13 +158,6 @@ class Graph(collections.defaultdict): text = '{%s}' % ', '.join(pairs) return encodeutils.safe_decode(text) - def leaves(self): - ''' - Return an iterator over all of the leaf nodes in the graph. - ''' - return (requirer for requirer, required in self.items() - if not required) - @staticmethod def toposort(graph): ''' @@ -256,6 +249,13 @@ class Dependencies(object): return Dependencies(edges) + def leaves(self): + ''' + Return an iterator over all of the leaf nodes in the graph. + ''' + return (requirer for requirer, required in self._graph.items() + if not required) + def translate(self, transform): ''' Translate all of the nodes using a transform function. diff --git a/heat/engine/stack.py b/heat/engine/stack.py index fec55d5ed3..a60c02abaf 100755 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -960,11 +960,7 @@ class Stack(collections.Mapping): self.convergence_dependencies.graph().edges()]} self.store() - leaves = (self.convergence_dependencies.graph(reverse=True).leaves() - if self.action in (self.DELETE, self.SUSPEND) - else self.convergence_dependencies.graph().leaves()) - - for rsrc_id, is_update in leaves: + for rsrc_id, is_update in self.convergence_dependencies.leaves(): LOG.info(_LI("Triggering resource %(rsrc_id)s " "for update=%(is_update)s"), {'rsrc_id': rsrc_id, 'is_update': is_update}) diff --git a/heat/tests/test_dependencies.py b/heat/tests/test_dependencies.py index 9159ff442e..f5b88e909a 100644 --- a/heat/tests/test_dependencies.py +++ b/heat/tests/test_dependencies.py @@ -227,10 +227,10 @@ class dependenciesTest(common.HeatTestCase): self.assertRaises(KeyError, d.required_by, 'foo') - def test_graph_leaves(self): + def test_leaves(self): d = dependencies.Dependencies([('last1', 'mid'), ('last2', 'mid'), ('mid', 'first1'), ('mid', 'first2')]) - leaves = sorted(list(d._graph.leaves())) + leaves = sorted(list(d.leaves())) self.assertEqual(['first1', 'first2'], leaves) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index be862aa7e1..9d11acbfb2 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -236,9 +236,9 @@ resources: ''' -class StackConvergenceCreateUpdateTest(common.HeatTestCase): +class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase): def setUp(self): - super(StackConvergenceCreateUpdateTest, self).setUp() + super(StackConvergenceCreateUpdateDeleteTest, self).setUp() cfg.CONF.set_override('convergence_engine', True) def test_conv_wordpress_single_instance_stack_create(self):