RPC Client: don't cast() delete_stack by default

The delete_stack() RPC call in the client can be sent using either call()
or cast(), with cast() the default. This is never what you want, because
the call could raise an exception and you want to hear about that.

We're now passing cast=False explicitly everywhere. We always were in
heat-cfn-api and heat-api, but failing to do so in StackResource caused bug
1499669, which was corrected by I039eb8f6c6a262653c1e9edc8173e5680d81e31b.
Changing the default to call() will prevent anyone making that same mistake
again.

Change-Id: Idd6a27988dadbf1cd8376de24b19f2226f6ae5b7
Related-Bug: #1499669
This commit is contained in:
Zane Bitter 2016-09-21 19:13:02 -04:00
parent d42ce99218
commit 73a886d806
2 changed files with 7 additions and 4 deletions

View File

@ -426,12 +426,15 @@ class EngineClient(object):
stack_identity=stack_identity),
version='1.32')
def delete_stack(self, ctxt, stack_identity, cast=True):
def delete_stack(self, ctxt, stack_identity, cast=False):
"""Deletes a given stack.
:param ctxt: RPC context.
:param stack_identity: Name of the stack you want to delete.
:param cast: cast the message or use call (default: True)
:param cast: cast the message instead of using call (default: False)
You probably never want to use cast(). If you do, you'll never hear
about any exceptions the call might raise.
"""
rpc_method = self.cast if cast else self.call
return rpc_method(ctxt,

View File

@ -85,8 +85,8 @@ class EngineRpcAPITestCase(common.HeatTestCase):
expected_message = self.rpcapi.make_msg(method, **kwargs)
cast_and_call = ['delete_stack']
if rpc_method == 'call' and method in cast_and_call:
kwargs['cast'] = False
if method in cast_and_call:
kwargs['cast'] = rpc_method != 'call'
with mock.patch.object(self.rpcapi, rpc_method) as mock_rpc_method:
mock_rpc_method.return_value = expected_retval