Convergence: Avoid sync point delete for stack CREATE

Previous traversal sync points should be deleted in case of concurrent
updates. However, in case of stack CREATE there won't be any previous
traversal sync points to delete.
Hence avoid hitting the DB.

Change-Id: If61332107a1f4d70a590f7db87b6c10bc9cf7b2c
changes/14/243714/4
Rakesh H S 7 years ago
parent 83b9ad952d
commit 441d52f0fe
  1. 6
      heat/engine/stack.py
  2. 25
      heat/tests/test_convg_stack.py

@ -1015,12 +1015,14 @@ class Stack(collections.Mapping):
self.store()
# delete the prev traversal sync_points
if previous_traversal:
sync_point.delete_all(self.context, self.id, previous_traversal)
# TODO(later): lifecycle_plugin_utils.do_pre_ops
self.state_set(action, self.IN_PROGRESS,
'Stack %s started' % action)
# delete the prev traversal sync_points
sync_point.delete_all(self.context, self.id, previous_traversal)
self._converge_create_or_update()
def _converge_create_or_update(self):

@ -461,6 +461,31 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
self.assertIsNotNone(stack.updated_time)
self.assertTrue(mock_ccu.called)
@mock.patch.object(parser.Stack, '_converge_create_or_update')
@mock.patch.object(sync_point_object.SyncPoint,
'delete_all_by_stack_and_traversal')
def test_sync_point_delete_stack_create(self, mock_syncpoint_del,
mock_ccu, mock_cr):
stack = parser.Stack(utils.dummy_context(), 'convg_updated_time_test',
templatem.Template.create_empty_template())
stack.converge_stack(template=stack.t, action=stack.CREATE)
self.assertFalse(mock_syncpoint_del.called)
self.assertTrue(mock_ccu.called)
@mock.patch.object(parser.Stack, '_converge_create_or_update')
@mock.patch.object(sync_point_object.SyncPoint,
'delete_all_by_stack_and_traversal')
def test_sync_point_delete_stack_update(self, mock_syncpoint_del,
mock_ccu, mock_cr):
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {'R1': {'Type': 'GenericResourceType'}}}
stack = parser.Stack(utils.dummy_context(), 'updated_time_test',
templatem.Template(tmpl))
stack.current_traversal = 'prev_traversal'
stack.converge_stack(template=stack.t, action=stack.UPDATE)
self.assertTrue(mock_syncpoint_del.called)
self.assertTrue(mock_ccu.called)
class TestConvgStackRollback(common.HeatTestCase):

Loading…
Cancel
Save