Skip to content

Commit

Permalink
ecu_tracker: log errors from failed local ecu status query
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed Dec 5, 2024
1 parent e3be330 commit b771c3f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/otaclient/grpc/api_v2/ecu_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import asyncio
import atexit
import contextlib
import logging
from collections import defaultdict

Expand All @@ -28,8 +27,19 @@
from otaclient.grpc.api_v2.ecu_status import ECUStatusStorage
from otaclient_api.v2 import types as api_types
from otaclient_api.v2.api_caller import ECUNoResponse, OTAClientCall
from otaclient_common.logging import BurstSuppressFilter

logger = logging.getLogger(__name__)
burst_suppressed_logger = logging.getLogger(f"{__name__}.local_ecu_check")
# NOTE: for request_error, only allow max 6 lines of logging per 30 seconds
burst_suppressed_logger.addFilter(
BurstSuppressFilter(
f"{__name__}.local_ecu_check",
upper_logger_name=__name__,
burst_round_length=30,
burst_max=6,
)
)

# actively polling ECUs status until we get the first valid response
# when otaclient is just starting.
Expand Down Expand Up @@ -84,11 +94,15 @@ async def _polling_local_ecu_status(self):
"""Task entry for loop polling local ECU status."""
my_ecu_id = ecu_info.ecu_id
while True:
with contextlib.suppress(Exception):
try:
status_report = self._local_ecu_status_reader.sync_msg()
if status_report:
self._startup_matrix[my_ecu_id] = False
await self._ecu_status_storage.update_from_local_ecu(status_report)
except Exception as e:
burst_suppressed_logger.warning(
f"failed to query local ECU's status: {e!r}"
)

if self._startup_matrix[my_ecu_id]:
await asyncio.sleep(_ACTIVE_POLL_LOCAL_ON_STARTUP)
Expand Down

0 comments on commit b771c3f

Please sign in to comment.