Skip to content

Making services more debuggable #1690

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

Merged
merged 6 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions services/sidecar/src/simcore_service_sidecar/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ async def run(self):
await self._post_messages(
LogType.LOG, "[sidecar]...task completed successfully."
)
except exceptions.SidecarException:
await self._post_messages(LogType.LOG, "[sidecar]...task failed.")
except exceptions.SidecarException as e:
await self._post_messages(LogType.LOG, f"[sidecar]...task failed: {str(e)}")
raise

async def preprocess(self):
Expand Down
11 changes: 9 additions & 2 deletions services/sidecar/src/simcore_service_sidecar/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
from enum import Enum
from pathlib import Path
import aiodocker
from typing import Awaitable, Callable, Tuple, Union

import aiofiles
Expand Down Expand Up @@ -78,8 +79,14 @@ async def monitor_logs_task(
async def _monitor_docker_container(
container: DockerContainer, log_cb: Awaitable[Callable[[LogType, str], None]]
) -> None:
async for line in container.log(stdout=True, stderr=True, follow=True):
log_type, parsed_line = await parse_line(line)
try:
async for line in container.log(stdout=True, stderr=True, follow=True):
log_type, parsed_line = await parse_line(line)
except aiodocker.exceptions.DockerError as e:
log_type, parsed_line = await parse_line(
f"Could not recover logs because: {str(e)}"
Comment on lines +85 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering, import aiodocker vs from aiodocker.exceptions import DockerError ? what are the implications? is there any typical python directive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no reason, but this way you know exactly from which module the error comes. It's more readable because sometimes you may have a GenericError and with this form except module.submodule.GenericError... is easier to read.

)
finally:
await log_cb(log_type, parsed_line)


Expand Down