mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
Small cleanup to be more robust (#1876)
This commit is contained in:
parent
d6d3bf0583
commit
311c981d1a
@ -5,6 +5,7 @@ import asyncio
|
|||||||
from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar
|
from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import sentry_sdk
|
||||||
|
|
||||||
from .config import CoreConfig
|
from .config import CoreConfig
|
||||||
from .const import UpdateChannels
|
from .const import UpdateChannels
|
||||||
@ -612,3 +613,7 @@ class CoreSysAttributes:
|
|||||||
def sys_create_task(self, coroutine: Coroutine) -> asyncio.Task:
|
def sys_create_task(self, coroutine: Coroutine) -> asyncio.Task:
|
||||||
"""Create an async task."""
|
"""Create an async task."""
|
||||||
return self.sys_loop.create_task(coroutine)
|
return self.sys_loop.create_task(coroutine)
|
||||||
|
|
||||||
|
def sys_capture_exception(self, err: Exception) -> None:
|
||||||
|
"""Capture a exception."""
|
||||||
|
sentry_sdk.capture_exception(err)
|
||||||
|
@ -217,11 +217,11 @@ class DockerInterface(CoreSysAttributes):
|
|||||||
except docker.errors.DockerException:
|
except docker.errors.DockerException:
|
||||||
raise DockerAPIError() from None
|
raise DockerAPIError() from None
|
||||||
|
|
||||||
_LOGGER.info("Start %s", self.image)
|
_LOGGER.info("Start %s", self.name)
|
||||||
try:
|
try:
|
||||||
docker_container.start()
|
docker_container.start()
|
||||||
except docker.errors.DockerException as err:
|
except docker.errors.DockerException as err:
|
||||||
_LOGGER.error("Can't start %s: %s", self.image, err)
|
_LOGGER.error("Can't start %s: %s", self.name, err)
|
||||||
raise DockerAPIError() from None
|
raise DockerAPIError() from None
|
||||||
|
|
||||||
@process_lock
|
@process_lock
|
||||||
|
@ -268,6 +268,8 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
_LOGGER.warning("Fails install landingpage, retry after 30sec")
|
_LOGGER.warning("Fails install landingpage, retry after 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
except Exception as err: # pylint: disable=broad-except
|
||||||
|
self.sys_capture_exception(err)
|
||||||
else:
|
else:
|
||||||
self.version = self.instance.version
|
self.version = self.instance.version
|
||||||
self.image = self.sys_updater.image_homeassistant
|
self.image = self.sys_updater.image_homeassistant
|
||||||
@ -290,11 +292,16 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
tag = self.latest_version
|
tag = self.latest_version
|
||||||
if tag:
|
if tag:
|
||||||
with suppress(DockerAPIError):
|
try:
|
||||||
await self.instance.update(
|
await self.instance.update(
|
||||||
tag, image=self.sys_updater.image_homeassistant
|
tag, image=self.sys_updater.image_homeassistant
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
except DockerAPIError:
|
||||||
|
pass
|
||||||
|
except Exception as err: # pylint: disable=broad-except
|
||||||
|
self.sys_capture_exception(err)
|
||||||
|
|
||||||
_LOGGER.warning("Error on install Home Assistant. Retry in 30sec")
|
_LOGGER.warning("Error on install Home Assistant. Retry in 30sec")
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(30)
|
||||||
|
|
||||||
@ -596,6 +603,7 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
# Skip landingpage
|
# Skip landingpage
|
||||||
if version == LANDINGPAGE:
|
if version == LANDINGPAGE:
|
||||||
return
|
return
|
||||||
|
_LOGGER.info("Wait until Home Assistant is ready")
|
||||||
|
|
||||||
# Manage timeouts
|
# Manage timeouts
|
||||||
timeout: bool = True
|
timeout: bool = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user