From f19560cd88ce2325603d346e4f94ce071fe4b065 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:08:11 +0000 Subject: [PATCH 01/14] otaclient._types: MultipleECUStatusFlags: rename any_in_update to any_child_ecu_in_update --- src/otaclient/_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/otaclient/_types.py b/src/otaclient/_types.py index 92981290d..603aaea5c 100644 --- a/src/otaclient/_types.py +++ b/src/otaclient/_types.py @@ -126,7 +126,7 @@ class OTAClientStatus: @dataclass class MultipleECUStatusFlags: - any_in_update: mp_sync.Event + any_child_ecu_in_update: mp_sync.Event any_requires_network: mp_sync.Event all_success: mp_sync.Event From 1ac7cc980379dfd0a91e24107b94ee70fcc5cbb8 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:08:32 +0000 Subject: [PATCH 02/14] otaclient.main: MultipleECUStatusFlags: rename any_in_update to any_child_ecu_in_update --- src/otaclient/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/otaclient/main.py b/src/otaclient/main.py index 4d0316993..cecb4391c 100644 --- a/src/otaclient/main.py +++ b/src/otaclient/main.py @@ -116,7 +116,7 @@ def main() -> None: # pragma: no cover local_otaclient_op_queue = mp_ctx.Queue() local_otaclient_resp_queue = mp_ctx.Queue() ecu_status_flags = MultipleECUStatusFlags( - any_in_update=mp_ctx.Event(), + any_child_ecu_in_update=mp_ctx.Event(), any_requires_network=mp_ctx.Event(), all_success=mp_ctx.Event(), ) From 7a57a6f77fd2cbcaed0709284e732a1ab5561116 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:11:40 +0000 Subject: [PATCH 03/14] ecu_status: set ecu_status_flags.any_child_ecu_in_update accordingly --- src/otaclient/grpc/api_v2/ecu_status.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index 66b8b68b3..a17909c06 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -195,10 +195,11 @@ async def _generate_overall_status_report(self): "new ECU(s) that acks update request and enters OTA update detected" f"{_new_in_update_ecu}, current updating ECUs: {in_update_ecus_id}" ) - if in_update_ecus_id: - ecu_status_flags.any_in_update.set() + + if self.in_update_child_ecus_id: + ecu_status_flags.any_child_ecu_in_update.set() else: - ecu_status_flags.any_in_update.clear() + ecu_status_flags.any_child_ecu_in_update.clear() # check if there is any failed child/self ECU in tracked active ECUs set _old_failed_ecus_id = self.failed_ecus_id @@ -346,7 +347,10 @@ async def on_ecus_accept_update_request(self, ecus_accept_update: set[str]): ecu_status_flags.all_success.clear() ecu_status_flags.any_requires_network.set() - ecu_status_flags.any_in_update.set() + if self.in_update_child_ecus_id: + ecu_status_flags.any_child_ecu_in_update.set() + else: + ecu_status_flags.any_child_ecu_in_update.clear() def get_polling_interval(self) -> int: """Return if there is active OTA update, @@ -355,11 +359,8 @@ def get_polling_interval(self) -> int: NOTE: use get_polling_waiter if want to wait, only call this method if one only wants to get the polling interval value. """ - ecu_status_flags = self.ecu_status_flags return ( - ACTIVE_POLLING_INTERVAL - if ecu_status_flags.any_in_update.is_set() - else IDLE_POLLING_INTERVAL + ACTIVE_POLLING_INTERVAL if self.in_update_ecus_id else IDLE_POLLING_INTERVAL ) def get_polling_waiter(self): @@ -377,13 +378,12 @@ def get_polling_waiter(self): _inner_wait_interval = 1 # second async def _waiter(): - ecu_status_flags = self.ecu_status_flags - if ecu_status_flags.any_in_update.is_set(): + if self.in_update_ecus_id: await asyncio.sleep(ACTIVE_POLLING_INTERVAL) return for _ in range(math.ceil(IDLE_POLLING_INTERVAL / _inner_wait_interval)): - if ecu_status_flags.any_in_update.is_set(): + if self.in_update_ecus_id: return await asyncio.sleep(_inner_wait_interval) From 2f5d3226388c85c11b9adad2b7be0f34bc401a1a Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:22:29 +0000 Subject: [PATCH 04/14] fix up test_ecu_status --- .../test_grpc/test_api_v2/test_ecu_status.py | 68 ++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py index 8e3081f8d..3fda7adc1 100644 --- a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py +++ b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py @@ -53,7 +53,7 @@ async def setup_test(self, mocker: MockerFixture, ecu_info_fixture: ECUInfo): # init and setup the ecu_storage # NOTE: here we use threading.Event instead self.ecu_status_flags = ecu_status_flags = MultipleECUStatusFlags( - any_in_update=threading.Event(), # type: ignore[assignment] + any_child_ecu_in_update=threading.Event(), # type: ignore[assignment] any_requires_network=threading.Event(), # type: ignore[assignment] all_success=threading.Event(), # type: ignore[assignment] ) @@ -380,7 +380,7 @@ async def test_export( }, # ecu_status_flags { - "any_in_update": True, + "any_child_ecu_in_update": True, "any_requires_network": True, "all_success": False, }, @@ -429,7 +429,7 @@ async def test_export( }, # ecu_status_flags { - "any_in_update": True, + "any_child_ecu_in_update": True, "any_requires_network": True, "all_success": False, }, @@ -510,7 +510,7 @@ async def test_overall_ecu_status_report_generation( }, # ecu_status_flags { - "any_in_update": True, + "any_child_ecu_in_update": True, "any_requires_network": True, "all_success": False, }, @@ -562,7 +562,56 @@ async def test_overall_ecu_status_report_generation( }, # ecu_status_flags { - "any_in_update": True, + "any_child_ecu_in_update": True, + "any_requires_network": True, + "all_success": False, + }, + ), + # case 3: + # only main ECU doing OTA update. + ( + # local ECU status: UPDATING + _internal_types.OTAClientStatus( + ota_status=_internal_types.OTAStatus.UPDATING, + update_phase=_internal_types.UpdatePhase.DOWNLOADING_OTA_FILES, + ), + # sub ECUs status + [ + # p1: SUCCESS + api_types.StatusResponse( + available_ecu_ids=["p1"], + ecu_v2=[ + api_types.StatusResponseEcuV2( + ecu_id="p1", + ota_status=api_types.StatusOta.SUCCESS, + ), + ], + ), + # p2: SUCCESS + api_types.StatusResponse( + available_ecu_ids=["p2"], + ecu=[ + api_types.StatusResponseEcu( + ecu_id="p2", + status=api_types.Status( + status=api_types.StatusOta.SUCCESS, + ), + ) + ], + ), + ], + ["p1"], + # expected overal ECUs status report set by on_ecus_accept_update_request, + { + "lost_ecus_id": set(), + "in_update_ecus_id": {"autoware"}, + "in_update_child_ecus_id": {}, + "failed_ecus_id": set(), + "success_ecus_id": {"p1", "p2"}, + }, + # ecu_status_flags + { + "any_child_ecu_in_update": False, "any_requires_network": True, "all_success": False, }, @@ -604,15 +653,18 @@ async def test_on_receive_update_request( for k, v in flags_status.items(): assert getattr(self.ecu_status_flags, k).is_set() == v - async def test_polling_waiter_switching_from_idling_to_active(self): + async def test_polling_waiter_switching_from_idling_to_active( + self, mocker: pytest_mock.MockerFixture + ): """Waiter should immediately return if active_ota_update_present is set.""" _sleep_time, _mocked_interval = 3, 60 + mocker.patch(f"{ECU_STATUS_MODULE}.IDLE_POLLING_INTERVAL", _mocked_interval) + async def _event_setter(): await asyncio.sleep(_sleep_time) - self.ecu_status_flags.any_in_update.set() + await self.ecu_storage.on_ecus_accept_update_request({"autoware"}) - self.ecu_status_flags.any_in_update.clear() _waiter = self.ecu_storage.get_polling_waiter() asyncio.create_task(_event_setter()) # waiter should return on active_ota_update_present is set, instead of waiting the From 276deffc572ef765a3ee00608f3bf99639100a6d Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:33:38 +0000 Subject: [PATCH 05/14] fix up test_ecu_status --- .../test_grpc/test_api_v2/test_ecu_status.py | 97 +++++++++---------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py index 3fda7adc1..0c02cd275 100644 --- a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py +++ b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py @@ -434,6 +434,54 @@ async def test_export( "all_success": False, }, ), + # case 3: + # only main ECU doing OTA update. + ( + # local ECU status: UPDATING + _internal_types.OTAClientStatus( + ota_status=_internal_types.OTAStatus.UPDATING, + update_phase=_internal_types.UpdatePhase.DOWNLOADING_OTA_FILES, + ), + # sub ECUs status + [ + # p1: SUCCESS + api_types.StatusResponse( + available_ecu_ids=["p1"], + ecu_v2=[ + api_types.StatusResponseEcuV2( + ecu_id="p1", + ota_status=api_types.StatusOta.SUCCESS, + ), + ], + ), + # p2: SUCCESS + api_types.StatusResponse( + available_ecu_ids=["p2"], + ecu=[ + api_types.StatusResponseEcu( + ecu_id="p2", + status=api_types.Status( + status=api_types.StatusOta.SUCCESS, + ), + ) + ], + ), + ], + # expected overal ECUs status report set by on_ecus_accept_update_request, + { + "lost_ecus_id": set(), + "in_update_ecus_id": {"autoware"}, + "in_update_child_ecus_id": {}, + "failed_ecus_id": set(), + "success_ecus_id": {"p1", "p2"}, + }, + # ecu_status_flags + { + "any_child_ecu_in_update": False, + "any_requires_network": True, + "all_success": False, + }, + ), ), ) async def test_overall_ecu_status_report_generation( @@ -567,55 +615,6 @@ async def test_overall_ecu_status_report_generation( "all_success": False, }, ), - # case 3: - # only main ECU doing OTA update. - ( - # local ECU status: UPDATING - _internal_types.OTAClientStatus( - ota_status=_internal_types.OTAStatus.UPDATING, - update_phase=_internal_types.UpdatePhase.DOWNLOADING_OTA_FILES, - ), - # sub ECUs status - [ - # p1: SUCCESS - api_types.StatusResponse( - available_ecu_ids=["p1"], - ecu_v2=[ - api_types.StatusResponseEcuV2( - ecu_id="p1", - ota_status=api_types.StatusOta.SUCCESS, - ), - ], - ), - # p2: SUCCESS - api_types.StatusResponse( - available_ecu_ids=["p2"], - ecu=[ - api_types.StatusResponseEcu( - ecu_id="p2", - status=api_types.Status( - status=api_types.StatusOta.SUCCESS, - ), - ) - ], - ), - ], - ["p1"], - # expected overal ECUs status report set by on_ecus_accept_update_request, - { - "lost_ecus_id": set(), - "in_update_ecus_id": {"autoware"}, - "in_update_child_ecus_id": {}, - "failed_ecus_id": set(), - "success_ecus_id": {"p1", "p2"}, - }, - # ecu_status_flags - { - "any_child_ecu_in_update": False, - "any_requires_network": True, - "all_success": False, - }, - ), ), ) async def test_on_receive_update_request( From 1fd899465e70e6ff815eb2464a9898c22a1491da Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:35:21 +0000 Subject: [PATCH 06/14] minor fix --- tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py index 0c02cd275..d032c9c74 100644 --- a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py +++ b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py @@ -471,7 +471,7 @@ async def test_export( { "lost_ecus_id": set(), "in_update_ecus_id": {"autoware"}, - "in_update_child_ecus_id": {}, + "in_update_child_ecus_id": set(), "failed_ecus_id": set(), "success_ecus_id": {"p1", "p2"}, }, From b4b954712f1a88d394829022b7ef4296ce614ffe Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 18 Dec 2024 07:51:29 +0000 Subject: [PATCH 07/14] ota_core: wait on any_child_ecu_in_update not set --- src/otaclient/ota_core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/otaclient/ota_core.py b/src/otaclient/ota_core.py index 77696ff64..c36759cad 100644 --- a/src/otaclient/ota_core.py +++ b/src/otaclient/ota_core.py @@ -579,11 +579,9 @@ def _execute_update(self): ) ) - # NOTE: we don't need to wait for sub ECUs if sub ECUs don't - # depend on otaproxy on this ECU. if proxy_info.enable_local_ota_proxy: wait_and_log( - check_flag=self.ecu_status_flags.any_requires_network.is_set, + check_flag=self.ecu_status_flags.any_child_ecu_in_update.is_set, check_for=False, message="permit reboot flag", log_func=logger.info, From fccf4fe8b2dcda3b55caf43fb82f90fd353f3929 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 05:32:01 +0000 Subject: [PATCH 08/14] test_create_standby: fix usage of ecu_status_flags --- tests/test_otaclient/test_create_standby.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_otaclient/test_create_standby.py b/tests/test_otaclient/test_create_standby.py index b0abbbec8..9ade8cd1b 100644 --- a/tests/test_otaclient/test_create_standby.py +++ b/tests/test_otaclient/test_create_standby.py @@ -106,7 +106,7 @@ def test_update_with_rebuild_mode( ): status_collector, status_report_queue = ota_status_collector ecu_status_flags = mocker.MagicMock() - ecu_status_flags.any_requires_network.is_set = mocker.MagicMock( + ecu_status_flags.any_child_ecu_in_update.is_set = mocker.MagicMock( return_value=False ) From 8002d7502e091fe7c3599c159b63472c507fae20 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 05:39:18 +0000 Subject: [PATCH 09/14] fix up tests according to ecu_status_flags --- tests/test_otaclient/test_create_standby.py | 2 +- tests/test_otaclient/test_ota_core.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_otaclient/test_create_standby.py b/tests/test_otaclient/test_create_standby.py index 9ade8cd1b..cb2abf3bf 100644 --- a/tests/test_otaclient/test_create_standby.py +++ b/tests/test_otaclient/test_create_standby.py @@ -145,7 +145,7 @@ def test_update_with_rebuild_mode( # ------ assertions ------ # persist_handler.assert_called_once() - ecu_status_flags.any_requires_network.is_set.assert_called_once() + ecu_status_flags.any_child_ecu_in_update.is_set.assert_called_once() # --- ensure the update stats are collected collected_status = status_collector.otaclient_status assert collected_status diff --git a/tests/test_otaclient/test_ota_core.py b/tests/test_otaclient/test_ota_core.py index ffaab77b0..397e59098 100644 --- a/tests/test_otaclient/test_ota_core.py +++ b/tests/test_otaclient/test_ota_core.py @@ -161,7 +161,7 @@ def test_otaupdater( ) -> None: _, report_queue = ota_status_collector ecu_status_flags = mocker.MagicMock() - ecu_status_flags.any_requires_network.is_set = mocker.MagicMock( + ecu_status_flags.any_child_ecu_in_update.is_set = mocker.MagicMock( return_value=False ) @@ -202,7 +202,7 @@ def test_otaupdater( assert _downloaded_files_size == self._delta_bundle.total_download_files_size # assert the control_flags has been waited - ecu_status_flags.any_requires_network.is_set.assert_called_once() + ecu_status_flags.any_child_ecu_in_update.is_set.assert_called_once() assert _updater.update_version == str(cfg.UPDATE_VERSION) @@ -235,7 +235,7 @@ def mock_setup( ): _, status_report_queue = ota_status_collector ecu_status_flags = mocker.MagicMock() - ecu_status_flags.any_requires_network.is_set = mocker.MagicMock( + ecu_status_flags.any_child_ecu_in_update.is_set = mocker.MagicMock( return_value=False ) From ae95a30319c63394bc675eb13fc12bc560dc4178 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 05:47:21 +0000 Subject: [PATCH 10/14] minor update --- src/otaclient/grpc/api_v2/ecu_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index a17909c06..0a88aac2e 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -340,10 +340,10 @@ async def on_ecus_accept_update_request(self, ecus_accept_update: set[str]): self.last_update_request_received_timestamp = int(time.time()) self.lost_ecus_id -= ecus_accept_update self.failed_ecus_id -= ecus_accept_update + self.success_ecus_id -= ecus_accept_update self.in_update_ecus_id.update(ecus_accept_update) self.in_update_child_ecus_id = self.in_update_ecus_id - {self.my_ecu_id} - self.success_ecus_id -= ecus_accept_update ecu_status_flags.all_success.clear() ecu_status_flags.any_requires_network.set() From e342b6881af46a80fb501d218d6782e78ebf1fe7 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 06:00:04 +0000 Subject: [PATCH 11/14] ecu_status: use available_ecu_ids instead of tracked_ecu_ids --- src/otaclient/grpc/api_v2/ecu_status.py | 32 +++++++------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index 0a88aac2e..899dc9ebe 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -95,26 +95,12 @@ def __init__( # ECU status storage self.storage_last_updated_timestamp = 0 - # ECUs that are/will be active during an OTA session, - # at init it will be the ECUs listed in available_ecu_ids defined - # in ecu_info.yaml. - # When receives update request, the list will be set to include ECUs - # listed in the update request, and be extended by merging - # available_ecu_ids in sub ECUs' status report. - # Internally referenced when generating overall ECU status report. - # TODO: in the future if otaclient can preserve OTA session info, - # ECUStatusStorage should restore the tracked_active_ecus info - # in the saved session info. - self._tracked_active_ecus: _OrderedSet[str] = _OrderedSet( - ecu_info.get_available_ecu_ids() - ) - # The attribute that will be exported in status API response, - # NOTE(20230801): available_ecu_ids only serves information purpose, - # it should only be updated with ecu_info.yaml or merging - # available_ecu_ids field in sub ECUs' status report. # NOTE(20230801): for web.auto user, available_ecu_ids in status API response # will be used to generate update request list, so be-careful! + # NOTE(20241219): we will only look at status of ECUs listed in available_ecu_ids. + # ECUs that in the secondaries field but no in available_ecu_ids field + # are considered to be the ECUs not ready for OTA. See ecu_info.yaml doc. self._available_ecu_ids: _OrderedSet[str] = _OrderedSet( ecu_info.get_available_ecu_ids() ) @@ -185,7 +171,7 @@ async def _generate_overall_status_report(self): for status in chain( self._all_ecus_status_v2.values(), self._all_ecus_status_v1.values() ) - if status.ecu_id in self._tracked_active_ecus + if status.ecu_id in self._available_ecu_ids and status.is_in_update and status.ecu_id not in lost_ecus } @@ -208,7 +194,7 @@ async def _generate_overall_status_report(self): for status in chain( self._all_ecus_status_v2.values(), self._all_ecus_status_v1.values() ) - if status.ecu_id in self._tracked_active_ecus + if status.ecu_id in self._available_ecu_ids and status.is_failed and status.ecu_id not in lost_ecus } @@ -224,7 +210,7 @@ async def _generate_overall_status_report(self): for status in chain( self._all_ecus_status_v2.values(), self._all_ecus_status_v1.values() ) - if status.ecu_id in self._tracked_active_ecus + if status.ecu_id in self._available_ecu_ids and status.ecu_id not in lost_ecus ) ): @@ -241,12 +227,12 @@ async def _generate_overall_status_report(self): for status in chain( self._all_ecus_status_v2.values(), self._all_ecus_status_v1.values() ) - if status.ecu_id in self._tracked_active_ecus + if status.ecu_id in self._available_ecu_ids and status.is_success and status.ecu_id not in lost_ecus } # NOTE: all_success doesn't count the lost ECUs - if len(self.success_ecus_id) == len(self._tracked_active_ecus): + if len(self.success_ecus_id) == len(self._available_ecu_ids): ecu_status_flags.all_success.set() else: ecu_status_flags.all_success.clear() @@ -335,8 +321,6 @@ async def on_ecus_accept_update_request(self, ecus_accept_update: set[str]): """ ecu_status_flags = self.ecu_status_flags async with self._properties_update_lock: - self._tracked_active_ecus = _OrderedSet(ecus_accept_update) - self.last_update_request_received_timestamp = int(time.time()) self.lost_ecus_id -= ecus_accept_update self.failed_ecus_id -= ecus_accept_update From cd2a5bf84dfd8f18dcee911bea92ebacd499db4f Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 06:19:19 +0000 Subject: [PATCH 12/14] ecu_status: no need to define our own version of OrderDict --- src/otaclient/grpc/api_v2/ecu_status.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index 899dc9ebe..bc5a8519a 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -44,7 +44,6 @@ import math import time from itertools import chain -from typing import Dict, Iterable, Optional from otaclient._types import MultipleECUStatusFlags, OTAClientStatus from otaclient.configs.cfg import cfg, ecu_info @@ -64,23 +63,6 @@ ACTIVE_POLLING_INTERVAL = 1 # seconds -class _OrderedSet(Dict[T, None]): - def __init__(self, _input: Optional[Iterable[T]]): - if _input: - for elem in _input: - self[elem] = None - super().__init__() - - def add(self, value: T): - self[value] = None - - def remove(self, value: T): - super().pop(value) - - def discard(self, value: T): - super().pop(value, None) - - class ECUStatusStorage: def __init__( @@ -101,7 +83,7 @@ def __init__( # NOTE(20241219): we will only look at status of ECUs listed in available_ecu_ids. # ECUs that in the secondaries field but no in available_ecu_ids field # are considered to be the ECUs not ready for OTA. See ecu_info.yaml doc. - self._available_ecu_ids: _OrderedSet[str] = _OrderedSet( + self._available_ecu_ids: dict[str, None] = dict.fromkeys( ecu_info.get_available_ecu_ids() ) From e83c718378482acaebd876b8a99e79bff6fc08b0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 06:20:12 +0000 Subject: [PATCH 13/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/otaclient/grpc/api_v2/ecu_status.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index bc5a8519a..9b2d538dd 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -49,7 +49,6 @@ from otaclient.configs.cfg import cfg, ecu_info from otaclient.grpc.api_v2.types import convert_to_apiv2_status from otaclient_api.v2 import types as api_types -from otaclient_common.typing import T logger = logging.getLogger(__name__) From c73b176a3e0b65ff01d185229e2befeeaedaaab0 Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Thu, 19 Dec 2024 06:22:46 +0000 Subject: [PATCH 14/14] minor fix --- src/otaclient/grpc/api_v2/ecu_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index 9b2d538dd..7ba274532 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -213,7 +213,7 @@ async def _generate_overall_status_report(self): and status.ecu_id not in lost_ecus } # NOTE: all_success doesn't count the lost ECUs - if len(self.success_ecus_id) == len(self._available_ecu_ids): + if self.success_ecus_id == set(self._available_ecu_ids): ecu_status_flags.all_success.set() else: ecu_status_flags.all_success.clear()