Drop unneeded/commented cancel-by-msg code; roots perms wasn't the problem

l1_precision_fix
Tyler Goodlet 2022-05-08 15:31:36 -04:00
parent 1676bceee1
commit fb9b6990ae
1 changed files with 1 additions and 48 deletions

View File

@ -128,7 +128,6 @@ async def open_docker(
finally: finally:
if client: if client:
client.close() client.close()
# client.api._custom_adapter.close()
for c in client.containers.list(): for c in client.containers.list():
c.kill() c.kill()
@ -210,7 +209,6 @@ class Container:
return True return True
except docker.errors.APIError as err: except docker.errors.APIError as err:
# _err = err
if 'is not running' in err.explanation: if 'is not running' in err.explanation:
return False return False
@ -223,17 +221,13 @@ class Container:
with trio.move_on_after(0.5) as cs: with trio.move_on_after(0.5) as cs:
cs.shield = True cs.shield = True
# print('PROCESSINGN LOGS')
await self.process_logs_until('initiating graceful shutdown') await self.process_logs_until('initiating graceful shutdown')
# print('SHUTDOWN REPORTED BY CONTAINER')
await self.process_logs_until('exiting...',) await self.process_logs_until('exiting...',)
for _ in range(10): for _ in range(10):
with trio.move_on_after(0.5) as cs: with trio.move_on_after(0.5) as cs:
cs.shield = True cs.shield = True
# print('waiting on EXITING')
await self.process_logs_until('exiting...',) await self.process_logs_until('exiting...',)
# print('got EXITING')
break break
if cs.cancelled_caught: if cs.cancelled_caught:
@ -280,7 +274,7 @@ async def open_marketstored(
5993:5993 alpacamarkets/marketstore:latest 5993:5993 alpacamarkets/marketstore:latest
''' '''
log = get_console_log('info', name=__name__) get_console_log('info', name=__name__)
async with open_docker() as client: async with open_docker() as client:
@ -335,8 +329,6 @@ async def open_marketstored(
await ctx.started((cntr.cntr.id, os.getpid())) await ctx.started((cntr.cntr.id, os.getpid()))
# async with ctx.open_stream() as stream:
try: try:
# TODO: we might eventually want a proxy-style msg-prot here # TODO: we might eventually want a proxy-style msg-prot here
@ -344,25 +336,6 @@ async def open_marketstored(
# callers to have root perms? # callers to have root perms?
await trio.sleep_forever() await trio.sleep_forever()
# await cntr.cancel()
# with trio.CancelScope(shield=True):
# # block for the expected "teardown log msg"..
# # await cntr.process_logs_until('exiting...',)
# # only msg should be to signal killing the
# # container and this super daemon.
# msg = await stream.receive()
# # print("GOT CANCEL MSG")
# cid = msg['cancel']
# log.cancel(f'Cancelling container {cid}')
# # print("CANCELLING CONTAINER")
# await cntr.cancel()
# # print("SENDING ACK")
# await stream.send('ack')
except ( except (
BaseException, BaseException,
# trio.Cancelled, # trio.Cancelled,
@ -371,7 +344,6 @@ async def open_marketstored(
with trio.CancelScope(shield=True): with trio.CancelScope(shield=True):
await cntr.cancel() await cntr.cancel()
# await stream.send('ack')
raise raise
@ -426,15 +398,6 @@ async def start_ahab(
cid, pid = first cid, pid = first
await trio.sleep_forever() await trio.sleep_forever()
# async with ctx.open_stream() as stream:
# try:
# # run till cancelled
# await trio.sleep_forever()
# finally:
# with trio.CancelScope(shield=True):
# # print('SENDING CANCEL TO MARKETSTORED')
# await stream.send({'cancel': (cid, pid)})
# assert await stream.receive() == 'ack'
# since we demoted root perms in this parent # since we demoted root perms in this parent
# we'll get a perms error on proc cleanup in # we'll get a perms error on proc cleanup in
@ -445,7 +408,6 @@ async def start_ahab(
# TODO: we could also consider adding # TODO: we could also consider adding
# a ``tractor.ZombieDetected`` or something that we could raise # a ``tractor.ZombieDetected`` or something that we could raise
# if we find the child didn't terminate. # if we find the child didn't terminate.
# await tractor.breakpoint()
except PermissionError: except PermissionError:
log.warning('Failed to cancel root permsed container') log.warning('Failed to cancel root permsed container')
@ -458,12 +420,3 @@ async def start_ahab(
return return
else: else:
raise raise
async def main():
await start_ahab()
await trio.sleep_forever()
if __name__ == '__main__':
trio.run(main)