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
This commit is contained in:
Rakesh H S 2015-05-05 14:22:02 +05:30
parent e4b959d75c
commit 9994950f40
4 changed files with 12 additions and 16 deletions

View File

@ -158,13 +158,6 @@ class Graph(collections.defaultdict):
text = '{%s}' % ', '.join(pairs) text = '{%s}' % ', '.join(pairs)
return encodeutils.safe_decode(text) 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 @staticmethod
def toposort(graph): def toposort(graph):
''' '''
@ -256,6 +249,13 @@ class Dependencies(object):
return Dependencies(edges) 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): def translate(self, transform):
''' '''
Translate all of the nodes using a transform function. Translate all of the nodes using a transform function.

View File

@ -960,11 +960,7 @@ class Stack(collections.Mapping):
self.convergence_dependencies.graph().edges()]} self.convergence_dependencies.graph().edges()]}
self.store() self.store()
leaves = (self.convergence_dependencies.graph(reverse=True).leaves() for rsrc_id, is_update in self.convergence_dependencies.leaves():
if self.action in (self.DELETE, self.SUSPEND)
else self.convergence_dependencies.graph().leaves())
for rsrc_id, is_update in leaves:
LOG.info(_LI("Triggering resource %(rsrc_id)s " LOG.info(_LI("Triggering resource %(rsrc_id)s "
"for update=%(is_update)s"), "for update=%(is_update)s"),
{'rsrc_id': rsrc_id, 'is_update': is_update}) {'rsrc_id': rsrc_id, 'is_update': is_update})

View File

@ -227,10 +227,10 @@ class dependenciesTest(common.HeatTestCase):
self.assertRaises(KeyError, d.required_by, 'foo') self.assertRaises(KeyError, d.required_by, 'foo')
def test_graph_leaves(self): def test_leaves(self):
d = dependencies.Dependencies([('last1', 'mid'), ('last2', 'mid'), d = dependencies.Dependencies([('last1', 'mid'), ('last2', 'mid'),
('mid', 'first1'), ('mid', 'first2')]) ('mid', 'first1'), ('mid', 'first2')])
leaves = sorted(list(d._graph.leaves())) leaves = sorted(list(d.leaves()))
self.assertEqual(['first1', 'first2'], leaves) self.assertEqual(['first1', 'first2'], leaves)

View File

@ -236,9 +236,9 @@ resources:
''' '''
class StackConvergenceCreateUpdateTest(common.HeatTestCase): class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
def setUp(self): def setUp(self):
super(StackConvergenceCreateUpdateTest, self).setUp() super(StackConvergenceCreateUpdateDeleteTest, self).setUp()
cfg.CONF.set_override('convergence_engine', True) cfg.CONF.set_override('convergence_engine', True)
def test_conv_wordpress_single_instance_stack_create(self): def test_conv_wordpress_single_instance_stack_create(self):