Skip to content

Commit d0f5ce3

Browse files
committed
fix(haos): bound beta image reconnects
1 parent d39fbc9 commit d0f5ce3

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

tests/haos_image_build/build_image.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ def _wait_core_version(
20332033

20342034
while time.monotonic() < deadline:
20352035
try:
2036-
ws.reconnect()
2036+
ws.reconnect(deadline=deadline)
20372037
last_info = ws.supervisor_api("/core/info", method="get", timeout=30.0)
20382038
except _SUPERVISOR_WAIT_TRANSIENT_ERRORS as exc:
20392039
if not _is_transient_supervisor_readiness_error(exc):
@@ -2062,10 +2062,11 @@ def _reconnect_during_supervisor_update(
20622062
ws: HAWebSocket,
20632063
*,
20642064
context: str,
2065+
deadline: float,
20652066
) -> BaseException | None:
20662067
"""Best-effort reconnect during a Supervisor restart window."""
20672068
try:
2068-
ws.reconnect()
2069+
ws.reconnect(deadline=deadline)
20692070
except _SUPERVISOR_WAIT_TRANSIENT_ERRORS as exc:
20702071
if not _is_transient_supervisor_readiness_error(exc):
20712072
raise
@@ -2097,6 +2098,7 @@ def _wait_supervisor_channel_metadata(
20972098
reconnect_error = _reconnect_during_supervisor_update(
20982099
ws,
20992100
context="during Supervisor channel reload",
2101+
deadline=deadline,
21002102
)
21012103
if reconnect_error is not None:
21022104
last_error = reconnect_error
@@ -2168,6 +2170,7 @@ def _apply_supervisor_image_update(
21682170
_reconnect_during_supervisor_update(
21692171
ws,
21702172
context="after Supervisor update",
2173+
deadline=deadline,
21712174
)
21722175
time.sleep(5.0)
21732176

tests/src/unit/test_haos_supervisor_wait.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
OAuthCredentials,
2424
WSCommandError,
2525
_configure_supervisor_image_variant,
26+
_reconnect_during_supervisor_update,
2627
_wait_core_version,
2728
_wait_supervisor_channel_metadata,
2829
_wait_supervisor_ready,
@@ -633,6 +634,24 @@ def test_channel_metadata_timeout_prefers_the_last_reconnect_error() -> None:
633634
deadline=1.0,
634635
)
635636

637+
ws.reconnect.assert_called_once_with(deadline=1.0)
638+
639+
640+
def test_supervisor_update_reconnect_propagates_deadline() -> None:
641+
"""Supervisor update reconnects retain the image-build deadline."""
642+
ws = Mock()
643+
644+
assert (
645+
_reconnect_during_supervisor_update(
646+
ws,
647+
context="during test",
648+
deadline=10.0,
649+
)
650+
is None
651+
)
652+
653+
ws.reconnect.assert_called_once_with(deadline=10.0)
654+
636655

637656
def test_wait_rejects_terminal_supervisor_error_without_retry() -> None:
638657
"""A terminal Supervisor command error propagates immediately."""
@@ -1183,7 +1202,7 @@ def test_wait_core_version_reports_non_convergence() -> None:
11831202
message = str(exc_info.value)
11841203
assert "expected='2026.8.3'" in message
11851204
assert repr(old_info) in message
1186-
ws.reconnect.assert_called_once_with()
1205+
ws.reconnect.assert_called_once_with(deadline=1.0)
11871206
ws.supervisor_api.assert_called_once_with("/core/info", method="get", timeout=30.0)
11881207
sleep.assert_called_once_with(0.0)
11891208

0 commit comments

Comments
 (0)