Skip to content

Commit

Permalink
aws_iot_logger: add logic to detect failure caused by failed mtls con…
Browse files Browse the repository at this point in the history
…nection
  • Loading branch information
Bodong-Yang committed Mar 4, 2024
1 parent 60f7a6a commit 82c22da
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/otaclient_iot_logging_server/aws_iot_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from queue import Empty
from threading import Thread

import awscrt.exceptions
from typing_extensions import NoReturn

from otaclient_iot_logging_server._common import LogEvent, LogMessage, LogsQueue
Expand Down Expand Up @@ -87,6 +88,14 @@ def _create_log_group(self):
logger.debug(
f"{log_group_name=} already existed, skip creating: {e.response}"
)
except ValueError as e:
if e.__cause__ and isinstance(e.__cause__, awscrt.exceptions.AwsCrtError):
logger.error(
(f"failed to create mtls connection to remote: {e.__cause__}")
)
raise e.__cause__
logger.error(f"failed to create {log_group_name=}: {e!r}")
raise
except Exception as e:
logger.error(f"failed to create {log_group_name=}: {e!r}")
raise
Expand All @@ -105,6 +114,14 @@ def _create_log_stream(self, log_stream_name: str):
logger.debug(
f"{log_stream_name=}@{log_group_name} already existed, skip creating: {e.response}"
)
except ValueError as e:
if e.__cause__ and isinstance(e.__cause__, awscrt.exceptions.AwsCrtError):
logger.error(
(f"failed to create mtls connection to remote: {e.__cause__}")
)
raise e.__cause__
logger.error(f"failed to create {log_stream_name=}@{log_group_name}: {e!r}")
raise
except Exception as e:
logger.error(f"failed to create {log_stream_name=}@{log_group_name}: {e!r}")
raise
Expand Down

0 comments on commit 82c22da

Please sign in to comment.