Skip to content

Commit cc2d7c1

Browse files
authored
fix: restart otaclient when client update is failed (#576)
1 parent fb75154 commit cc2d7c1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/otaclient/ota_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,9 +1208,9 @@ def client_update(self, request: ClientUpdateRequestV2) -> None:
12081208
).execute()
12091209
except ota_errors.OTAError:
12101210
# TODO(airkei) [2025-06-19]: should return the dedicated error code for "client update"
1211-
self._exit_from_dynamic_client()
1211+
self._client_update_control_flags.request_shutdown_event.set()
12121212
except Exception:
1213-
self._exit_from_dynamic_client()
1213+
self._client_update_control_flags.request_shutdown_event.set()
12141214

12151215
def rollback(self, request: RollbackRequestV2) -> None:
12161216
self._live_ota_status = OTAStatus.ROLLBACKING

tests/test_otaclient/test_ota_core.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,14 @@ def test_client_update_interrupted(self, mocker: pytest_mock.MockerFixture):
268268
"""Test client update with interruption."""
269269
from otaclient._types import ClientUpdateRequestV2
270270

271-
mock_exit_from_dynamic_client = mocker.patch.object(
272-
self.ota_client, "_exit_from_dynamic_client"
273-
)
274-
275271
# inject exception
276272
_error = OTAErrorRecoverable(
277273
"client update interrupted by test as expected", module=__name__
278274
)
279275
self.ota_client_updater.execute.side_effect = _error
276+
self.ota_client._client_update_control_flags.request_shutdown_event.set = (
277+
mocker.MagicMock()
278+
)
280279

281280
# --- execution --- #
282281
self.ota_client.client_update(
@@ -291,8 +290,8 @@ def test_client_update_interrupted(self, mocker: pytest_mock.MockerFixture):
291290
# --- assertion on interrupted client update --- #
292291
self.ota_client_updater.execute.assert_called_once()
293292

294-
# Verify that _exit_from_dynamic_client was called
295-
mock_exit_from_dynamic_client.assert_called_once()
293+
# Verify that request_shutdown_event was set
294+
self.ota_client._client_update_control_flags.request_shutdown_event.set.assert_called_once()
296295

297296

298297
class TestOTAClientUpdater:

0 commit comments

Comments
 (0)