Fix TypeError exception during cancel stack update

TypeError: call() takes exactly 3 arguments(5 given) is raised
during cancel stack update, this patch will fix the problem.

Change-Id: If85389150a15575d9e01466d950f8c07b8fa2717
Closes-Bug: #1448384
This commit is contained in:
huangtianhua 2015-04-25 18:16:32 +08:00
parent 23e10121b0
commit 7240396203
2 changed files with 27 additions and 3 deletions

View File

@ -806,7 +806,7 @@ class EngineService(service.Service):
elif stack_lock.StackLock.engine_alive(cnxt, engine_id):
cancel_result = self._remote_call(
cnxt, engine_id, self.listener.SEND,
stack_identity, rpc_api.THREAD_CANCEL)
stack_identity=stack_identity, message=rpc_api.THREAD_CANCEL)
if cancel_result is None:
LOG.debug("Successfully sent %(msg)s message "
"to remote task on engine %(eng)s" % {
@ -902,7 +902,7 @@ class EngineService(service.Service):
return s.raw_template.template
return None
def _remote_call(self, cnxt, lock_engine_id, call, *args, **kwargs):
def _remote_call(self, cnxt, lock_engine_id, call, **kwargs):
timeout = cfg.CONF.engine_life_check_timeout
self.cctxt = self._client.prepare(
version='1.0',
@ -910,7 +910,7 @@ class EngineService(service.Service):
topic=rpc_api.LISTENER_TOPIC,
server=lock_engine_id)
try:
self.cctxt.call(cnxt, call, *args, **kwargs)
self.cctxt.call(cnxt, call, **kwargs)
except messaging.MessagingTimeout:
return False

View File

@ -27,6 +27,7 @@ import six
from heat.common import context
from heat.common import exception
from heat.common import identifier
from heat.common import messaging
from heat.common import service_utils
from heat.common import template_format
from heat.engine.clients.os import swift
@ -986,6 +987,29 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
self.man.thread_group_mgr.send.assert_called_once_with(old_stack.id,
'cancel')
def test_stack_cancel_update_different_engine(self):
stack_name = 'service_update_cancel_test_stack'
old_stack = tools.get_stack(stack_name, self.ctx)
old_stack.state_set(old_stack.UPDATE, old_stack.IN_PROGRESS,
'test_override')
old_stack.disable_rollback = False
old_stack.store()
load_mock = self.patchobject(parser.Stack, 'load')
load_mock.return_value = old_stack
lock_mock = self.patchobject(stack_lock.StackLock, 'try_acquire')
another_engine_has_lock = str(uuid.uuid4())
lock_mock.return_value = another_engine_has_lock
self.patchobject(stack_lock.StackLock,
'engine_alive').return_value(True)
self.man.listener = mock.Mock()
self.man.listener.SEND = 'send'
self.man._client = messaging.get_rpc_client(
version=self.man.RPC_API_VERSION)
# In fact the another engine is not alive, so the call will timeout
self.assertRaises(dispatcher.ExpectedException,
self.man.stack_cancel_update,
self.ctx, old_stack.identifier())
def test_stack_cancel_update_wrong_state_fails(self):
stack_name = 'service_update_cancel_test_stack'
old_stack = tools.get_stack(stack_name, self.ctx)