Merge "Set COMPLETE for failed resource if no update/replace" into stable/ocata

This commit is contained in:
Jenkins 2017-05-24 10:54:47 +00:00 committed by Gerrit Code Review
commit 75962e46bd
2 changed files with 22 additions and 0 deletions

View File

@ -1326,6 +1326,12 @@ class Resource(object):
if not self._needs_update(after, before,
after_props, before_props,
prev_resource):
if self.status == self.FAILED:
status_reason = _('Update status to COMPLETE for '
'FAILED resource neither update '
'nor replace.')
self.state_set(self.action, self.COMPLETE,
status_reason)
return
if not self.stack.convergence:

View File

@ -499,6 +499,22 @@ class ResourceTest(common.HeatTestCase):
self.assertFalse(res.needs_replace_failed.called)
self.assertTrue(res.prepare_for_replace.called)
def test_no_update_or_replace_in_failed(self):
res, utmpl = self._setup_resource_for_update(
res_name='test_failed_res_no_update_or_replace')
res.state_set(res.CREATE, res.FAILED)
res.prepare_for_replace = mock.Mock()
res.needs_replace_failed = mock.MagicMock(return_value=False)
scheduler.TaskRunner(res.update, res.t)()
self.assertTrue(res.needs_replace_failed.called)
self.assertFalse(res.prepare_for_replace.called)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
status_reason = _('Update status to COMPLETE for '
'FAILED resource neither update '
'nor replace.')
self.assertEqual(status_reason, res.status_reason)
def test_update_replace_prepare_replace_error(self):
# test if any error happened when prepare_for_replace,
# whether the resource will go to FAILED