Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a nested nexus action in stormservice deletion #1876

Merged
merged 5 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion synapse/cortex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,8 @@ async def _runStormSvcAdd(self, iden):
await self.svchive.set(iden, sdef)

async def runStormSvcEvent(self, iden, name):
assert name in ('add', 'del')

sdef = self.svchive.get(iden)
if sdef is None:
mesg = f'No storm service with iden: {iden}'
Expand All @@ -1576,7 +1578,13 @@ async def runStormSvcEvent(self, iden, name):
evnt = sdef.get('evts', {}).get(name, {}).get('storm')
if evnt is None:
return
await s_common.aspin(self.storm(evnt, opts={'vars': {'cmdconf': {'svciden': iden}}}))

opts = {'vars': {'cmdconf': {'svciden': iden}}}
coro = s_common.aspin(self.storm(evnt, opts=opts))
if name is 'add':
vEpiphyte marked this conversation as resolved.
Show resolved Hide resolved
invisig0th marked this conversation as resolved.
Show resolved Hide resolved
await coro
else:
self.schedCoro(coro)

async def _setStormSvc(self, sdef):

Expand Down
9 changes: 5 additions & 4 deletions synapse/tests/test_lib_stormsvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class RealService(s_stormsvc.StormSvc):
'storm': '$lib.queue.add(vertex)',
},
'del': {
'storm': '$lib.queue.del(vertex)',
'storm': '$que=$lib.queue.get(vertex) $que.put(done)',
},
}

Expand Down Expand Up @@ -611,9 +611,10 @@ async def test_storm_svcs(self):
# make sure stormcmd got deleted
self.none(core.getStormCmd('ohhai'))

# ensure fini ran
queue = core.multiqueue.list()
self.len(0, queue)
# ensure del event ran
q = 'for ($offs, $mesg) in $lib.queue.get(vertex).gets(wait=10) {return (($offs, $mesg))}'
retn = await core.callStorm(q)
self.eq(retn, (0, 'done'))

# specifically call teardown
for svc in core.getStormSvcs():
Expand Down