mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-08-01 05:17:42 +00:00
Block OS updates when the system is unhealthy (#6053)
* Block OS updates when the system is unhealthy In #6024 we mark a system as unhealthy when multiple OS installations were found. The idea was to block OS updates in this case. However, it turns out that the OS update job was not checking the system health and thus allowed updates even when the system was marked as unhealthy. This commit adds the `JobCondition.HEALTHY` condition to the OS update job, ensuring that OS updates are only performed when the system is healthy. Users can force an OS update still by using `ha jobs options --ignore-conditions healthy`. * Add test for update of unhealthy system --------- Co-authored-by: Jan Čermák <sairon@sairon.cz>
This commit is contained in:
parent
3af13cb7e2
commit
27b092aed0
@ -272,6 +272,7 @@ class OSManager(CoreSysAttributes):
|
||||
name="os_manager_update",
|
||||
conditions=[
|
||||
JobCondition.HAOS,
|
||||
JobCondition.HEALTHY,
|
||||
JobCondition.INTERNET_SYSTEM,
|
||||
JobCondition.RUNNING,
|
||||
JobCondition.SUPERVISOR_UPDATED,
|
||||
|
@ -9,6 +9,7 @@ import pytest
|
||||
from supervisor.const import CoreState
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.exceptions import HassOSJobError
|
||||
from supervisor.resolution.const import UnhealthyReason
|
||||
|
||||
from tests.common import MockResponse
|
||||
from tests.dbus_service_mocks.base import DBusServiceMock
|
||||
@ -85,6 +86,21 @@ async def test_update_fails_if_out_of_date(
|
||||
await coresys.os.update()
|
||||
|
||||
|
||||
async def test_update_fails_if_unhealthy(
|
||||
coresys: CoreSys,
|
||||
) -> None:
|
||||
"""Test update of OS fails if Supervisor is unhealthy."""
|
||||
await coresys.core.set_state(CoreState.RUNNING)
|
||||
coresys.resolution.add_unhealthy_reason(UnhealthyReason.DUPLICATE_OS_INSTALLATION)
|
||||
with (
|
||||
patch.object(
|
||||
type(coresys.os), "available", new=PropertyMock(return_value=True)
|
||||
),
|
||||
pytest.raises(HassOSJobError),
|
||||
):
|
||||
await coresys.os.update()
|
||||
|
||||
|
||||
async def test_board_name_supervised(coresys: CoreSys) -> None:
|
||||
"""Test board name is supervised when not on haos."""
|
||||
with patch("supervisor.os.manager.CPE.get_product", return_value=["not-hassos"]):
|
||||
|
Loading…
x
Reference in New Issue
Block a user