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,28 +217,23 @@ class RemoteStack(resource.Resource):
|
||||||
|
|
||||||
def _check_action_complete(self, action):
|
def _check_action_complete(self, action):
|
||||||
stack = self.heat().stacks.get(stack_id=self.resource_id)
|
stack = self.heat().stacks.get(stack_id=self.resource_id)
|
||||||
if stack.action == action:
|
if stack.action != action:
|
||||||
if stack.status == self.IN_PROGRESS:
|
return False
|
||||||
return False
|
|
||||||
elif stack.status == self.COMPLETE:
|
if stack.status == self.IN_PROGRESS:
|
||||||
return True
|
return False
|
||||||
elif stack.status == self.FAILED:
|
elif stack.status == self.COMPLETE:
|
||||||
raise resource.ResourceInError(
|
return True
|
||||||
resource_status=stack.stack_status,
|
elif stack.status == self.FAILED:
|
||||||
status_reason=stack.stack_status_reason)
|
raise resource.ResourceInError(
|
||||||
else:
|
resource_status=stack.stack_status,
|
||||||
# Note: this should never happen, so it really means that
|
status_reason=stack.stack_status_reason)
|
||||||
# the resource/engine is in serious problem if it happens.
|
|
||||||
raise resource.ResourceUnknownStatus(
|
|
||||||
resource_status=stack.stack_status,
|
|
||||||
status_reason=stack.stack_status_reason)
|
|
||||||
else:
|
else:
|
||||||
msg = _('Resource action mismatch detected: expected=%(expected)s '
|
# Note: this should never happen, so it really means that
|
||||||
'actual=%(actual)s') % dict(expected=action,
|
# the resource/engine is in serious problem if it happens.
|
||||||
actual=stack.action)
|
|
||||||
raise resource.ResourceUnknownStatus(
|
raise resource.ResourceUnknownStatus(
|
||||||
resource_status=stack.stack_status,
|
resource_status=stack.stack_status,
|
||||||
status_reason=msg)
|
status_reason=stack.stack_status_reason)
|
||||||
|
|
||||||
def check_create_complete(self, *args):
|
def check_create_complete(self, *args):
|
||||||
return self._check_action_complete(action=self.CREATE)
|
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)
|
self.heat.stacks.get = mock.MagicMock(side_effect=side_effect)
|
||||||
scheduler.TaskRunner(rsrc.update, update_snippet)()
|
scheduler.TaskRunner(rsrc.update, update_snippet)()
|
||||||
self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
|
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