Use the correct action for failure reason

Use `action` from ResourceFailure exception, if available, as
there are cases like update restriction check, where we don't
update the resource action yet.

Change-Id: I5d43c220669c7a9e8d7dbce6611e062101f8b86b
Closes-Bug: #1592631
changes/62/329762/1
Rabi Mishra 6 years ago
parent 9722a78840
commit 992e3b2d09
  1. 3
      heat/engine/check_resource.py
  2. 3
      heat/tests/test_resource.py

@ -123,7 +123,8 @@ class CheckResource(object):
rpc_data, is_update,
adopt_stack_data)
except exception.ResourceFailure as ex:
reason = 'Resource %s failed: %s' % (rsrc.action,
action = ex.action or rsrc.action
reason = 'Resource %s failed: %s' % (action,
six.text_type(ex))
self._handle_resource_failure(cnxt, is_update, rsrc.id,
stack, reason)

@ -3738,6 +3738,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.assertEqual('ResourceActionRestricted: resources.bar: '
'update is restricted for resource.',
six.text_type(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
'update is restricted for resource.')
@ -3763,6 +3764,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.assertEqual('ResourceActionRestricted: resources.bar: '
'replace is restricted for resource.',
six.text_type(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
'replace is restricted for resource.')
@ -3837,6 +3839,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.assertEqual('ResourceActionRestricted: resources.bar: '
'replace is restricted for resource.',
six.text_type(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
'replace is restricted for resource.')

Loading…
Cancel
Save