Split homeassistant watchdog conditions (#3318)

This commit is contained in:
Joakim Sørensen 2021-11-29 17:03:49 +01:00 committed by GitHub
parent 19e3a859b0
commit d0e2c8b694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,19 +170,20 @@ class Tasks(CoreSysAttributes):
async def _watchdog_homeassistant_docker(self): async def _watchdog_homeassistant_docker(self):
"""Check running state of Docker and start if they is close.""" """Check running state of Docker and start if they is close."""
# if Home Assistant is active if not self.sys_homeassistant.watchdog:
if ( # Watchdog is not enabled for Home Assistant
not await self.sys_homeassistant.core.is_failed()
or not self.sys_homeassistant.watchdog
or self.sys_homeassistant.error_state
):
return return
if self.sys_homeassistant.error_state:
# if Home Assistant is running # Home Assistant is in an error state, this is handled by the rollback feature
if ( return
self.sys_homeassistant.core.in_progress if not await self.sys_homeassistant.core.is_failed():
or await self.sys_homeassistant.core.is_running() # The home assistant container is not in a failed state
): return
if self.sys_homeassistant.core.in_progress:
# Home Assistant has a task in progress
return
if await self.sys_homeassistant.core.is_running():
# Home Assistant is running
return return
_LOGGER.warning("Watchdog found a problem with Home Assistant Docker!") _LOGGER.warning("Watchdog found a problem with Home Assistant Docker!")
@ -203,24 +204,25 @@ class Tasks(CoreSysAttributes):
Try 2 times to call API before we restart Home-Assistant. Maybe we had Try 2 times to call API before we restart Home-Assistant. Maybe we had
a delay in our system. a delay in our system.
""" """
# Home-Assistant is active/running if not self.sys_homeassistant.watchdog:
if ( # Watchdog is not enabled for Home Assistant
not await self.sys_homeassistant.core.is_running() return
or not self.sys_homeassistant.watchdog if self.sys_homeassistant.error_state:
or self.sys_homeassistant.error_state # Home Assistant is in an error state, this is handled by the rollback feature
): return
if not await self.sys_homeassistant.core.is_running():
# The home assistant container is not running
return
if self.sys_homeassistant.core.in_progress:
# Home Assistant has a task in progress
return
if await self.sys_homeassistant.api.check_api_state():
# Home Assistant is running properly
return return
# Init cache data # Init cache data
retry_scan = self._cache.get(HASS_WATCHDOG_API, 0) retry_scan = self._cache.get(HASS_WATCHDOG_API, 0)
# Home-Assistant API is up
if (
self.sys_homeassistant.core.in_progress
or await self.sys_homeassistant.api.check_api_state()
):
return
# Look like we run into a problem # Look like we run into a problem
retry_scan += 1 retry_scan += 1
if retry_scan == 1: if retry_scan == 1: