Add _add_event at the end of update_task

This patch adds call of _add_event method at the end of the update_task.
So now in event-list output user can see, that updating stack is
completed or failed.
Also status reason for update_task were changed to be inline with status
reason in the main stack_task method.

Method set_state is not used due to using stack.store method in the end
of update to avoid duplicate update.

Change-Id: Ic94c95f1558fd67f351696645426c00de8db1bf8
Closes-Bug: #1465321
This commit is contained in:
Sergey Kraynev 2015-06-15 11:02:34 -04:00
parent 7d9b5a265f
commit 9c052e9452
2 changed files with 5 additions and 7 deletions

View File

@ -1152,12 +1152,8 @@ class Stack(collections.Mapping):
finally:
self.reset_dependencies()
if action == self.UPDATE:
reason = 'Stack successfully updated'
elif action == self.RESTORE:
reason = 'Stack successfully restored'
else:
reason = 'Stack rollback completed'
if action in (self.UPDATE, self.RESTORE, self.ROLLBACK):
reason = 'Stack %s completed successfully' % action
stack_status = self.COMPLETE
except scheduler.Timeout:
@ -1198,7 +1194,9 @@ class Stack(collections.Mapping):
self.status_reason = reason
notification.send(self)
self._add_event(self.action, self.status, self.status_reason)
self.store()
lifecycle_plugin_utils.do_post_ops(self.context, self,
newstack, action,
(self.status == self.FAILED))

View File

@ -1522,7 +1522,7 @@ class StackServiceTest(common.HeatTestCase):
self.assertTrue(result['stack_id'])
events = self.eng.list_events(self.ctx, self.stack.identifier())
self.assertEqual(9, len(events))
self.assertEqual(10, len(events))
for ev in events:
self.assertIn('event_identity', ev)