mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-09 18:26:30 +00:00
Watchdog does not start core before supervisor (#4955)
This commit is contained in:
parent
02c6011818
commit
9ca927dbe7
@ -86,7 +86,9 @@ class HomeAssistantCore(JobGroup):
|
||||
await self.instance.get_latest_version()
|
||||
)
|
||||
|
||||
await self.instance.attach(version=self.sys_homeassistant.version)
|
||||
await self.instance.attach(
|
||||
version=self.sys_homeassistant.version, skip_state_event_if_down=True
|
||||
)
|
||||
except DockerError:
|
||||
_LOGGER.info(
|
||||
"No Home Assistant Docker image %s found.", self.sys_homeassistant.image
|
||||
@ -115,7 +117,9 @@ class HomeAssistantCore(JobGroup):
|
||||
"""Install a landing page."""
|
||||
# Try to use a preinstalled landingpage
|
||||
try:
|
||||
await self.instance.attach(version=LANDINGPAGE)
|
||||
await self.instance.attach(
|
||||
version=LANDINGPAGE, skip_state_event_if_down=True
|
||||
)
|
||||
except DockerError:
|
||||
pass
|
||||
else:
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Test Home Assistant watchdog."""
|
||||
import asyncio
|
||||
from unittest.mock import PropertyMock, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, PropertyMock, patch
|
||||
|
||||
from awesomeversion import AwesomeVersion
|
||||
|
||||
@ -135,3 +135,30 @@ async def test_home_assistant_watchdog_rebuild_on_failure(coresys: CoreSys) -> N
|
||||
await asyncio.sleep(0)
|
||||
start.assert_called_once()
|
||||
rebuild.assert_called_once()
|
||||
|
||||
|
||||
async def test_home_assistant_watchdog_skip_on_load(
|
||||
coresys: CoreSys, container: MagicMock
|
||||
) -> None:
|
||||
"""Test home assistant watchdog skips a crash event on load."""
|
||||
container.status = "stopped"
|
||||
container.attrs["State"]["ExitCode"] = 1
|
||||
coresys.homeassistant.core.watchdog = True
|
||||
|
||||
events = AsyncMock()
|
||||
coresys.bus.register_event(BusEvent.DOCKER_CONTAINER_STATE_CHANGE, events)
|
||||
|
||||
coresys.homeassistant.version = AwesomeVersion("2022.7.3")
|
||||
with patch(
|
||||
"supervisor.docker.interface.DockerInterface.version",
|
||||
new=PropertyMock(return_value=AwesomeVersion("2022.7.3")),
|
||||
), patch.object(
|
||||
type(coresys.homeassistant.core), "restart"
|
||||
) as restart, patch.object(type(coresys.homeassistant.core), "start") as start:
|
||||
await coresys.homeassistant.core.load()
|
||||
|
||||
# No events should be raised on attach
|
||||
await asyncio.sleep(0)
|
||||
events.assert_not_called()
|
||||
restart.assert_not_called()
|
||||
start.assert_not_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user