Don't raise error if actions are mismatched
Heat stack_resource has similar check for actions, but currently it does not raise error if actions are different. OS::Heat::Stack resource is similar on stack_resource so it has same issue, when resources require some time to change state/action and it should not be so strict. Change-Id: I20c2d3f8900b7393b1f551384805a35d5ef6497d Closes-Bug: #1454589
This commit is contained in:
parent
4032e40cce
commit
ef6ec7b652
|
@ -217,7 +217,9 @@ class RemoteStack(resource.Resource):
|
|||
|
||||
def _check_action_complete(self, action):
|
||||
stack = self.heat().stacks.get(stack_id=self.resource_id)
|
||||
if stack.action == action:
|
||||
if stack.action != action:
|
||||
return False
|
||||
|
||||
if stack.status == self.IN_PROGRESS:
|
||||
return False
|
||||
elif stack.status == self.COMPLETE:
|
||||
|
@ -232,13 +234,6 @@ class RemoteStack(resource.Resource):
|
|||
raise resource.ResourceUnknownStatus(
|
||||
resource_status=stack.stack_status,
|
||||
status_reason=stack.stack_status_reason)
|
||||
else:
|
||||
msg = _('Resource action mismatch detected: expected=%(expected)s '
|
||||
'actual=%(actual)s') % dict(expected=action,
|
||||
actual=stack.action)
|
||||
raise resource.ResourceUnknownStatus(
|
||||
resource_status=stack.stack_status,
|
||||
status_reason=msg)
|
||||
|
||||
def check_create_complete(self, *args):
|
||||
return self._check_action_complete(action=self.CREATE)
|
||||
|
|
|
@ -593,24 +593,3 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
|||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||
scheduler.TaskRunner(rsrc.update, update_snippet)()
|
||||
self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
|
||||
|
||||
def test_stack_status_error(self):
|
||||
returns = [get_stack(stack_status='DELETE_IN_PROGRESS'),
|
||||
get_stack(stack_status='UPDATE_COMPLETE')]
|
||||
|
||||
def side_effect_d(*args, **kwargs):
|
||||
return returns.pop(0)
|
||||
|
||||
rsrc = self.create_remote_stack()
|
||||
|
||||
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect_d)
|
||||
self.heat.stacks.delete = mock.MagicMock()
|
||||
remote_stack_id = rsrc.resource_id
|
||||
error = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
reason = ('Resource action mismatch detected: expected=DELETE '
|
||||
'actual=UPDATE')
|
||||
error_msg = ('ResourceUnknownStatus: Resource failed - Unknown '
|
||||
'status UPDATE_COMPLETE due to "%s"') % reason
|
||||
self.assertEqual(error_msg, six.text_type(error))
|
||||
self.heat.stacks.delete.assert_called_with(stack_id=remote_stack_id)
|
||||
|
|
Loading…
Reference in New Issue