mirror of
https://github.com/home-assistant/supervisor
synced 2024-10-02 06:19:58 +02:00
Make evaluation of container better (#2316)
This commit is contained in:
parent
e09a839148
commit
2d294f6841
@ -303,6 +303,7 @@ def setup_diagnostics(coresys: CoreSys) -> None:
|
|||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
|
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
|
||||||
before_send=lambda event, hint: filter_data(coresys, event, hint),
|
before_send=lambda event, hint: filter_data(coresys, event, hint),
|
||||||
|
auto_enabling_integrations=False,
|
||||||
integrations=[AioHttpIntegration(), sentry_logging],
|
integrations=[AioHttpIntegration(), sentry_logging],
|
||||||
release=SUPERVISOR_VERSION,
|
release=SUPERVISOR_VERSION,
|
||||||
max_breadcrumbs=30,
|
max_breadcrumbs=30,
|
||||||
|
@ -3,7 +3,6 @@ import logging
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
from ..exceptions import HassioError
|
|
||||||
from .checks.base import CheckBase
|
from .checks.base import CheckBase
|
||||||
from .checks.free_space import CheckFreeSpace
|
from .checks.free_space import CheckFreeSpace
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ class ResolutionCheck(CoreSysAttributes):
|
|||||||
for test in self.all_tests:
|
for test in self.all_tests:
|
||||||
try:
|
try:
|
||||||
await test()
|
await test()
|
||||||
except HassioError as err:
|
except Exception as err: # pylint: disable=broad-except
|
||||||
_LOGGER.warning("Error during processing %s: %s", test.issue, err)
|
_LOGGER.warning("Error during processing %s: %s", test.issue, err)
|
||||||
self.sys_capture_exception(err)
|
self.sys_capture_exception(err)
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from supervisor.exceptions import HassioError
|
|
||||||
|
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
from .const import UnhealthyReason, UnsupportedReason
|
from .const import UnhealthyReason, UnsupportedReason
|
||||||
from .evaluations.base import EvaluateBase
|
from .evaluations.base import EvaluateBase
|
||||||
@ -69,7 +67,7 @@ class ResolutionEvaluation(CoreSysAttributes):
|
|||||||
for evaluation in self.all_evalutions:
|
for evaluation in self.all_evalutions:
|
||||||
try:
|
try:
|
||||||
await evaluation()
|
await evaluation()
|
||||||
except HassioError as err:
|
except Exception as err: # pylint: disable=broad-except
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Error during processing %s: %s", evaluation.reason, err
|
"Error during processing %s: %s", evaluation.reason, err
|
||||||
)
|
)
|
||||||
|
@ -13,9 +13,8 @@ from .base import EvaluateBase
|
|||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
DOCKER_IMAGE_DENYLIST = [
|
DOCKER_IMAGE_DENYLIST = [
|
||||||
"containrrr/watchtower",
|
"watchtower",
|
||||||
"pyouroboros/ouroboros",
|
"ouroboros",
|
||||||
"v2tec/watchtower",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -41,16 +40,21 @@ class EvaluateContainer(EvaluateBase):
|
|||||||
@property
|
@property
|
||||||
def states(self) -> List[CoreState]:
|
def states(self) -> List[CoreState]:
|
||||||
"""Return a list of valid states when this evaluation can run."""
|
"""Return a list of valid states when this evaluation can run."""
|
||||||
return [CoreState.SETUP, CoreState.RUNNING]
|
return [CoreState.SETUP, CoreState.RUNNING, CoreState.INITIALIZE]
|
||||||
|
|
||||||
async def evaluate(self) -> None:
|
async def evaluate(self) -> None:
|
||||||
"""Run evaluation."""
|
"""Run evaluation."""
|
||||||
self._images.clear()
|
self._images.clear()
|
||||||
for image in await self.sys_run_in_executor(self._get_images):
|
for image in await self.sys_run_in_executor(self._get_images):
|
||||||
for tag in image.tags:
|
for tag in image.tags:
|
||||||
image_name = tag.split(":")[0]
|
image_name = tag.partition(":")[0].split("/")[-1]
|
||||||
|
|
||||||
|
# Evalue system
|
||||||
if (
|
if (
|
||||||
image_name in DOCKER_IMAGE_DENYLIST
|
any(
|
||||||
|
image_name.startswith(deny_name)
|
||||||
|
for deny_name in DOCKER_IMAGE_DENYLIST
|
||||||
|
)
|
||||||
and image_name not in self._images
|
and image_name not in self._images
|
||||||
):
|
):
|
||||||
self._images.add(image_name)
|
self._images.add(image_name)
|
||||||
|
@ -2,10 +2,8 @@
|
|||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from supervisor.exceptions import HassioError
|
|
||||||
from supervisor.resolution.data import Suggestion
|
|
||||||
|
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
|
from .data import Suggestion
|
||||||
from .fixups.base import FixupBase
|
from .fixups.base import FixupBase
|
||||||
from .fixups.clear_full_snapshot import FixupClearFullSnapshot
|
from .fixups.clear_full_snapshot import FixupClearFullSnapshot
|
||||||
from .fixups.create_full_snapshot import FixupCreateFullSnapshot
|
from .fixups.create_full_snapshot import FixupCreateFullSnapshot
|
||||||
@ -49,7 +47,7 @@ class ResolutionFixup(CoreSysAttributes):
|
|||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
await fix()
|
await fix()
|
||||||
except HassioError as err:
|
except Exception as err: # pylint: disable=broad-except
|
||||||
_LOGGER.warning("Error during processing %s: %s", fix.suggestion, err)
|
_LOGGER.warning("Error during processing %s: %s", fix.suggestion, err)
|
||||||
self.sys_capture_exception(err)
|
self.sys_capture_exception(err)
|
||||||
|
|
||||||
|
@ -6,10 +6,7 @@ from docker.errors import DockerException
|
|||||||
|
|
||||||
from supervisor.const import CoreState
|
from supervisor.const import CoreState
|
||||||
from supervisor.coresys import CoreSys
|
from supervisor.coresys import CoreSys
|
||||||
from supervisor.resolution.evaluations.container import (
|
from supervisor.resolution.evaluations.container import EvaluateContainer
|
||||||
DOCKER_IMAGE_DENYLIST,
|
|
||||||
EvaluateContainer,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_images(coresys: CoreSys):
|
def test_get_images(coresys: CoreSys):
|
||||||
@ -37,7 +34,16 @@ async def test_evaluation(coresys: CoreSys):
|
|||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"supervisor.resolution.evaluations.container.EvaluateContainer._get_images",
|
"supervisor.resolution.evaluations.container.EvaluateContainer._get_images",
|
||||||
return_value=[MagicMock(tags=[f"{DOCKER_IMAGE_DENYLIST[0]}:latest"])],
|
return_value=[
|
||||||
|
MagicMock(
|
||||||
|
tags=[
|
||||||
|
"armhfbuild/watchtower:latest",
|
||||||
|
"concerco/watchtowerv6:10.0.2",
|
||||||
|
"containrrr/watchtower:1.1",
|
||||||
|
"pyouroboros/ouroboros:1.4.3",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
],
|
||||||
):
|
):
|
||||||
await container()
|
await container()
|
||||||
assert container.reason in coresys.resolution.unsupported
|
assert container.reason in coresys.resolution.unsupported
|
||||||
|
Loading…
Reference in New Issue
Block a user