Mark resources UPDATE_COMPLETE when they request replacement

When a resource plugin requests for a resource to be replaced (e.g. by
raising UpdateReplace in handle_update()), mark the resource as
UPDATE_COMPLETE with the reason, instead of leaving it as
UPDATE_IN_PROGRESS.

Change-Id: I966b04908e6739bbadadeb20ba94ca8322c95f7d
Closes-Bug: #1560688
This commit is contained in:
Zane Bitter 2016-03-28 16:26:20 -04:00
parent 451f8c70ac
commit 1ecf93c19c
2 changed files with 4 additions and 3 deletions

View File

@ -696,14 +696,15 @@ class Resource(object):
raised, or FAILED otherwise. Non-exit exceptions will be translated
to ResourceFailure exceptions.
Expected exceptions are re-raised, with the Resource left in the
IN_PROGRESS state.
Expected exceptions are re-raised, with the Resource moved to the
COMPLETE state.
"""
try:
self.state_set(action, self.IN_PROGRESS)
yield
except expected_exceptions as ex:
with excutils.save_and_reraise_exception():
self.state_set(action, self.COMPLETE, six.text_type(ex))
LOG.debug('%s', six.text_type(ex))
except Exception as ex:
LOG.info(_LI('%(action)s: %(info)s'),

View File

@ -1024,7 +1024,7 @@ class StackUpdateTest(common.HeatTestCase):
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(11, len(events))
self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
self.assertEqual(5, mock_db_update.call_count)