Skip to content

Commit

Permalink
Improve error feedback for notebook-reachable check.
Browse files Browse the repository at this point in the history
  • Loading branch information
csadorf committed Feb 17, 2022
1 parent 5dcf03f commit 53f3f34
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions aiidalab_launch/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,26 @@ async def _notebook_service_online(container: Container) -> None:
loop = asyncio.get_event_loop()
LOGGER.debug("Waiting for notebook service to become reachable...")
while True:
LOGGER.debug("Curl notebook...")
result = await loop.run_in_executor(
None,
container.exec_run,
"curl --fail-early --fail --silent --max-time 1.0 http://localhost:8888",
)
if result.exit_code == 0:
LOGGER.debug("Notebook service reachable.")
return # jupyter is online
elif result.exit_code in (7, 28):
await asyncio.sleep(2) # jupyter not yet reachable
continue
else:
raise FailedToWaitForServices("Failed to reach notebook service.")
try:
LOGGER.debug("Curl notebook...")
result = await loop.run_in_executor(
None,
container.exec_run,
"curl --fail-early --fail --silent --max-time 1.0 http://localhost:8888",
)
if result.exit_code == 0:
LOGGER.debug("Notebook service reachable.")
return # jupyter is online
elif result.exit_code in (7, 28):
await asyncio.sleep(2) # jupyter not yet reachable
continue
else:
raise FailedToWaitForServices("Failed to reach notebook service.")
except docker.errors.APIError:
LOGGER.error("Failed to reach notebook service. Aborting.")
raise FailedToWaitForServices(
"Failed to reach notebook service (unable to reach container."
)

@staticmethod
async def _host_port_assigned(container: Container) -> None:
Expand Down

0 comments on commit 53f3f34

Please sign in to comment.