Allow kill-child-proc-with-root-perms to fail silently in `tractor` reaping
parent
981735669c
commit
c63eb91f6f
|
@ -167,7 +167,7 @@ async def open_docker(
|
||||||
|
|
||||||
|
|
||||||
@tractor.context
|
@tractor.context
|
||||||
async def open_marketstore(
|
async def open_marketstored(
|
||||||
ctx: tractor.Context,
|
ctx: tractor.Context,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
||||||
|
@ -272,8 +272,9 @@ async def open_marketstore(
|
||||||
await process_logs_until('exiting...',)
|
await process_logs_until('exiting...',)
|
||||||
|
|
||||||
except (
|
except (
|
||||||
trio.Cancelled,
|
BaseException,
|
||||||
KeyboardInterrupt,
|
# trio.Cancelled,
|
||||||
|
# KeyboardInterrupt,
|
||||||
):
|
):
|
||||||
cntr.kill('SIGINT')
|
cntr.kill('SIGINT')
|
||||||
with trio.move_on_after(0.5) as cs:
|
with trio.move_on_after(0.5) as cs:
|
||||||
|
@ -310,6 +311,7 @@ async def start_ahab(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
cn_ready = trio.Event()
|
cn_ready = trio.Event()
|
||||||
|
try:
|
||||||
async with tractor.open_nursery(
|
async with tractor.open_nursery(
|
||||||
loglevel='runtime',
|
loglevel='runtime',
|
||||||
) as tn:
|
) as tn:
|
||||||
|
@ -319,6 +321,11 @@ async def start_ahab(
|
||||||
enable_modules=[__name__]
|
enable_modules=[__name__]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: we have issues with this on teardown
|
||||||
|
# where ``tractor`` tries to issue ``os.kill()``
|
||||||
|
# and hits perms errors since the root process
|
||||||
|
# doesn't any longer have root perms..
|
||||||
|
|
||||||
# de-escalate root perms to the original user
|
# de-escalate root perms to the original user
|
||||||
# after the docker supervisor actor is spawned.
|
# after the docker supervisor actor is spawned.
|
||||||
if config._parent_user:
|
if config._parent_user:
|
||||||
|
@ -332,13 +339,36 @@ async def start_ahab(
|
||||||
task_status.started(cn_ready)
|
task_status.started(cn_ready)
|
||||||
|
|
||||||
async with portal.open_context(
|
async with portal.open_context(
|
||||||
open_marketstore,
|
open_marketstored,
|
||||||
) as (ctx, first):
|
) as (ctx, first):
|
||||||
|
|
||||||
assert str(first)
|
assert str(first)
|
||||||
# run till cancelled
|
# run till cancelled
|
||||||
await trio.sleep_forever()
|
await trio.sleep_forever()
|
||||||
|
|
||||||
|
# since we demoted root perms in this parent
|
||||||
|
# we'll get a perms error on proc cleanup in
|
||||||
|
# ``tractor`` nursery exit. just make sure
|
||||||
|
# the child is terminated and don't raise the
|
||||||
|
# error if so.
|
||||||
|
|
||||||
|
# TODO: we could also consider adding
|
||||||
|
# a ``tractor.ZombieDetected`` or something that we could raise
|
||||||
|
# if we find the child didn't terminate.
|
||||||
|
# await tractor.breakpoint()
|
||||||
|
except PermissionError:
|
||||||
|
log.warning('Failed to cancel root permsed container')
|
||||||
|
|
||||||
|
except (
|
||||||
|
trio.MultiError,
|
||||||
|
) as err:
|
||||||
|
for subexc in err.exceptions:
|
||||||
|
if isinstance(subexc, PermissionError):
|
||||||
|
log.warning('Failed to cancel root perms-ed container')
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
await start_ahab()
|
await start_ahab()
|
||||||
|
|
Loading…
Reference in New Issue