Do not throw an exception if stack outputs is not set
In some rare cases, stack output is not set and this line throws
an exception. This causes stack deletion to fail.
Change-Id: I7710f160ee881e355e3a3541fe8729b06ff29b38
Closes-Bug: #1638741
Co-Authored-By: Crag Wolfe <cwolfe@redhat.com>
(cherry picked from commit 349e67b451
)
This commit is contained in:
parent
4d1674cbce
commit
26fc290661
|
@ -596,7 +596,7 @@ class StackResource(resource.Resource):
|
|||
dict(stack_identity))
|
||||
if not stack:
|
||||
return
|
||||
outputs = stack[0][rpc_api.STACK_OUTPUTS]
|
||||
outputs = stack[0].get(rpc_api.STACK_OUTPUTS) or {}
|
||||
self._outputs = {o[rpc_api.OUTPUT_KEY]: o[rpc_api.OUTPUT_VALUE]
|
||||
for o in outputs if rpc_api.OUTPUT_ERROR not in o}
|
||||
|
||||
|
|
|
@ -643,6 +643,18 @@ class StackResourceAttrTest(StackResourceBaseTest):
|
|||
self.parent_resource.get_output,
|
||||
"key")
|
||||
|
||||
def test_get_output_key_no_outputs_from_rpc(self):
|
||||
self.parent_resource.nested_identifier = mock.Mock()
|
||||
self.parent_resource.nested_identifier.return_value = {'foo': 'bar'}
|
||||
|
||||
self.parent_resource._rpc_client = mock.MagicMock()
|
||||
output = {}
|
||||
self.parent_resource._rpc_client.show_stack.return_value = [output]
|
||||
|
||||
self.assertRaises(exception.InvalidTemplateAttribute,
|
||||
self.parent_resource.get_output,
|
||||
"key")
|
||||
|
||||
def test_resolve_attribute_string(self):
|
||||
self.parent_resource.nested_identifier = mock.Mock()
|
||||
self.parent_resource.nested_identifier.return_value = {'foo': 'bar'}
|
||||
|
|
Loading…
Reference in New Issue