From d29bb1927489d5590f17d2f3ef2904b6f5edd0d4 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 14 May 2015 16:50:36 -0400 Subject: [PATCH] Pass stack to thread in resource_signal This is the only thread that gets started without an explicit reference to the stack. This prevents us from using a weakref in the resource, as it will cause the Stack's reference count to hit 0 before the thread is run. Now we explicitly pass a reference to the stack. Change-Id: Ie51be7b54d97ef184e401e395a7e7e3a26ce003b Related-Bug: #1454873 --- heat/engine/service.py | 7 +++---- heat/tests/test_engine_service.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/heat/engine/service.py b/heat/engine/service.py index 0eb02b84d8..cb78aa17ca 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -1173,8 +1173,7 @@ class EngineService(service.Service): implementation. ''' - def _resource_signal(rsrc, details): - stack = rsrc.stack + def _resource_signal(stack, rsrc, details): LOG.debug("signaling resource %s:%s" % (stack.name, rsrc.name)) rsrc.signal(details) @@ -1199,11 +1198,11 @@ class EngineService(service.Service): rsrc = stack[resource_name] if callable(rsrc.signal): if sync_call: - _resource_signal(rsrc, details) + _resource_signal(stack, rsrc, details) return rsrc.metadata_get() else: self.thread_group_mgr.start(stack.id, _resource_signal, - rsrc, details) + stack, rsrc, details) @context.request_context def find_physical_resource(self, cnxt, physical_resource_id): diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 8628c34789..b8972314f7 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -2935,6 +2935,7 @@ class StackServiceTest(common.HeatTestCase): self.eng.thread_group_mgr.groups[stack.id] = tools.DummyThreadGroup() self.m.StubOutWithMock(self.eng.thread_group_mgr, 'start') self.eng.thread_group_mgr.start(stack.id, + mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(None)