Merge "Only recreate CHECK FAILED resources in ResourceGroup" into stable/ocata
This commit is contained in:
commit
138fafbb81
|
@ -94,11 +94,6 @@ class StackResource(resource.Resource):
|
|||
def _needs_update(self, after, before, after_props, before_props,
|
||||
prev_resource, check_init_complete=True):
|
||||
|
||||
# If stack resource is in CHECK_FAILED state, raise UpdateReplace
|
||||
# to replace the failed stack.
|
||||
if self.state == (self.CHECK, self.FAILED):
|
||||
raise resource.UpdateReplace(self)
|
||||
|
||||
# If the nested stack has not been created, use the default
|
||||
# implementation to determine if we need to replace the resource. Note
|
||||
# that we do *not* return the result.
|
||||
|
@ -107,6 +102,21 @@ class StackResource(resource.Resource):
|
|||
after_props, before_props,
|
||||
prev_resource,
|
||||
check_init_complete)
|
||||
else:
|
||||
if self.state == (self.CHECK, self.FAILED):
|
||||
nested_stack = self.rpc_client().show_stack(
|
||||
self.context, self.nested_identifier())[0]
|
||||
nested_stack_state = (nested_stack[rpc_api.STACK_ACTION],
|
||||
nested_stack[rpc_api.STACK_STATUS])
|
||||
if nested_stack_state == (self.stack.CHECK, self.stack.FAILED):
|
||||
# The stack-check action marked the stack resource
|
||||
# CHECK_FAILED, so return True to allow the individual
|
||||
# CHECK_FAILED resources decide if they need updating.
|
||||
return True
|
||||
# The mark-unhealthy action marked the stack resource
|
||||
# CHECK_FAILED, so raise UpdateReplace to replace the
|
||||
# entire failed stack.
|
||||
raise resource.UpdateReplace(self)
|
||||
|
||||
# Always issue an update to the nested stack and let the individual
|
||||
# resources in it decide if they need updating.
|
||||
|
|
|
@ -523,6 +523,12 @@ class StackResourceTest(StackResourceBaseTest):
|
|||
need update.
|
||||
"""
|
||||
self.parent_resource.action = self.parent_resource.CREATE
|
||||
|
||||
self.parent_resource._rpc_client = mock.MagicMock()
|
||||
self.parent_resource._rpc_client.show_stack.return_value = [
|
||||
{'stack_action': self.parent_resource.CREATE,
|
||||
'stack_status': self.parent_resource.COMPLETE}]
|
||||
|
||||
need_update = self.parent_resource._needs_update(
|
||||
self.parent_resource.t,
|
||||
self.parent_resource.t,
|
||||
|
@ -566,12 +572,8 @@ class StackResourceTest(StackResourceBaseTest):
|
|||
self.parent_resource.properties,
|
||||
self.parent_resource)
|
||||
|
||||
def test_need_update_in_check_failed_state_for_nested_resource(self):
|
||||
"""Test the resource should need replacement.
|
||||
|
||||
The resource in check_failed state should need update with
|
||||
UpdateReplace.
|
||||
"""
|
||||
def test_need_update_in_check_failed_state_after_stack_check(self):
|
||||
self.parent_resource.resource_id = 'fake_id'
|
||||
self.parent_resource.state_set(self.parent_resource.CHECK,
|
||||
self.parent_resource.FAILED)
|
||||
self.nested = mock.MagicMock()
|
||||
|
@ -579,6 +581,32 @@ class StackResourceTest(StackResourceBaseTest):
|
|||
self.parent_resource.nested = mock.MagicMock(return_value=self.nested)
|
||||
self.parent_resource._nested = self.nested
|
||||
|
||||
self.parent_resource._rpc_client = mock.MagicMock()
|
||||
self.parent_resource._rpc_client.show_stack.return_value = [
|
||||
{'stack_action': self.parent_resource.CHECK,
|
||||
'stack_status': self.parent_resource.FAILED}]
|
||||
|
||||
self.assertTrue(
|
||||
self.parent_resource._needs_update(self.parent_resource.t,
|
||||
self.parent_resource.t,
|
||||
self.parent_resource.properties,
|
||||
self.parent_resource.properties,
|
||||
self.parent_resource))
|
||||
|
||||
def test_need_update_check_failed_state_after_mark_unhealthy(self):
|
||||
self.parent_resource.resource_id = 'fake_id'
|
||||
self.parent_resource.state_set(self.parent_resource.CHECK,
|
||||
self.parent_resource.FAILED)
|
||||
self.nested = mock.MagicMock()
|
||||
self.nested.name = 'nested-stack'
|
||||
self.parent_resource.nested = mock.MagicMock(return_value=self.nested)
|
||||
self.parent_resource._nested = self.nested
|
||||
|
||||
self.parent_resource._rpc_client = mock.MagicMock()
|
||||
self.parent_resource._rpc_client.show_stack.return_value = [
|
||||
{'stack_action': self.parent_resource.CREATE,
|
||||
'stack_status': self.parent_resource.COMPLETE}]
|
||||
|
||||
self.assertRaises(resource.UpdateReplace,
|
||||
self.parent_resource._needs_update,
|
||||
self.parent_resource.t,
|
||||
|
|
Loading…
Reference in New Issue