Fix to send only one notification when update completes

Presently when an update is COMPLETE/FAILED, two events are reported.

In update_task we are already sending notification when an update
completes, however due to recent changes, notifications are also
sent at the time of releasing stack lock.

For update, we need not send notification when releasing lock.

Change-Id: Idc81f87b143dc43fa5409798534646d8400559ff
Closes-Bug: #1516090
This commit is contained in:
Rakesh H S 2015-11-16 20:23:26 +05:30
parent fde2da4f01
commit 411360f7d1
3 changed files with 7 additions and 3 deletions

View File

@ -178,7 +178,7 @@ class ThreadGroupManager(object):
releasing the lock to avoid race condtitions.
"""
if stack is not None and stack.action not in (
stack.DELETE, stack.ROLLBACK):
stack.DELETE, stack.ROLLBACK, stack.UPDATE):
stack.persist_state_and_release_lock(lock.engine_id)
else:
lock.release()

View File

@ -109,7 +109,6 @@ class StackEventTest(common.HeatTestCase):
result = self.eng.update_stack(self.ctx, self.stack.identifier(),
new_tmpl, None, None, {})
self.stack._persist_state()
# The self.stack reference needs to be updated. Since the underlying
# stack is updated in update_stack, the original reference is now
@ -121,7 +120,7 @@ class StackEventTest(common.HeatTestCase):
self.assertTrue(result['stack_id'])
events = self.eng.list_events(self.ctx, self.stack.identifier())
self.assertEqual(11, len(events))
self.assertEqual(10, len(events))
for ev in events:
self.assertIn('event_identity', ev)

View File

@ -924,6 +924,7 @@ class StackUpdateTest(common.HeatTestCase):
self.stack.create()
self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE),
self.stack.state)
self.stack._persist_state()
tmpl2 = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {'AResource': {'Type': 'ResourceWithPropsType',
@ -944,6 +945,10 @@ class StackUpdateTest(common.HeatTestCase):
self.stack.update(updated_stack)
self.assertEqual((stack.Stack.ROLLBACK, stack.Stack.COMPLETE),
self.stack.state)
self.eng = service.EngineService('a-host', 'a-topic')
events = self.eng.list_events(self.ctx, self.stack.identifier())
self.assertEqual(10, len(events))
self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
self.assertEqual(5, mock_db_update.call_count)
self.assertEqual('UPDATE',