From 72403962033d15bfe910eae14f01a4461d1789e9 Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Sat, 25 Apr 2015 18:16:32 +0800 Subject: [PATCH] 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 --- heat/engine/service.py | 6 +++--- heat/tests/test_engine_service.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/heat/engine/service.py b/heat/engine/service.py index 73ee234523..ea4d3b60ae 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -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 diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 6b8ff952d9..f04035cc8a 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -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)