From d73c10f8744f6017071244629783f632afcf304b Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 17 Aug 2020 10:44:40 +0200 Subject: [PATCH] Don't break startup with corrupt docker filesystem (#1936) --- supervisor/core.py | 14 +++++++++++--- supervisor/docker/__init__.py | 21 +++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/supervisor/core.py b/supervisor/core.py index 419898559..b3c81f28a 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -7,7 +7,12 @@ import async_timeout from .const import SOCKET_DBUS, SUPERVISED_SUPPORTED_OS, AddonStartup, CoreStates from .coresys import CoreSys, CoreSysAttributes -from .exceptions import HassioError, HomeAssistantError, SupervisorUpdateError +from .exceptions import ( + DockerAPIError, + HassioError, + HomeAssistantError, + SupervisorUpdateError, +) _LOGGER: logging.Logger = logging.getLogger(__name__) @@ -144,8 +149,11 @@ class Core(CoreSysAttributes): _LOGGER.error("Systemd DBUS is not connected") # Check if image names from denylist exist - if await self.sys_run_in_executor(self.sys_docker.check_denylist_images): - self.coresys.supported = False + try: + if await self.sys_run_in_executor(self.sys_docker.check_denylist_images): + self.coresys.supported = False + self.healthy = False + except DockerAPIError: self.healthy = False async def start(self): diff --git a/supervisor/docker/__init__.py b/supervisor/docker/__init__.py index 0edab3b37..6505e9b80 100644 --- a/supervisor/docker/__init__.py +++ b/supervisor/docker/__init__.py @@ -237,14 +237,19 @@ class DockerAPI: def check_denylist_images(self) -> bool: """Return a boolean if the host has images in the denylist.""" denied_images = set() - for image in self.images.list(): - for tag in image.tags: - image_name = tag.split(":")[0] - if ( - image_name in DOCKER_IMAGE_DENYLIST - and image_name not in denied_images - ): - denied_images.add(image_name) + + try: + for image in self.images.list(): + for tag in image.tags: + image_name = tag.split(":")[0] + if ( + image_name in DOCKER_IMAGE_DENYLIST + and image_name not in denied_images + ): + denied_images.add(image_name) + except (docker.errors.DockerException, requests.RequestException) as err: + _LOGGER.error("Corrupt docker overlayfs detect: %s", err) + raise DockerAPIError() if not denied_images: return False