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
This commit is contained in:
Zane Bitter 2015-05-14 16:50:36 -04:00
parent 203b8e8ecf
commit d29bb19274
2 changed files with 4 additions and 4 deletions

View File

@ -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):

View File

@ -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)