Don't break startup with corrupt docker filesystem (#1936)

This commit is contained in:
Pascal Vizeli 2020-08-17 10:44:40 +02:00 committed by GitHub
parent 9e448b46ba
commit d73c10f874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 11 deletions

View File

@ -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):

View File

@ -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