Detect lxc (#1754)

* Detect LXC on health check

* fix lint

* Update supervisor/core.py

Co-authored-by: Franck Nijhof <git@frenck.dev>

* fix black

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Pascal Vizeli 2020-05-26 14:12:19 +02:00 committed by GitHub
parent 18e3eacd7f
commit 960b00d85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -48,6 +48,12 @@ class Core(CoreSysAttributes):
"Docker version %s is not supported by Supervisor!", "Docker version %s is not supported by Supervisor!",
self.sys_docker.info.version, self.sys_docker.info.version,
) )
elif self.sys_docker.info.inside_lxc:
self.healthy = False
_LOGGER.critical(
"Detected Docker running inside LXC. Running Home Assistant with the Supervisor on LXC is not supported!"
)
self.sys_docker.info.check_requirements() self.sys_docker.info.check_requirements()
# Check if system is healthy # Check if system is healthy

View File

@ -2,6 +2,7 @@
from contextlib import suppress from contextlib import suppress
from ipaddress import IPv4Address from ipaddress import IPv4Address
import logging import logging
from pathlib import Path
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
import attr import attr
@ -46,6 +47,11 @@ class DockerInfo:
return version_local >= version_min return version_local >= version_min
@property
def inside_lxc(self) -> bool:
"""Return True if the docker run inside lxc."""
return Path("/dev/lxd/sock").exists()
def check_requirements(self) -> None: def check_requirements(self) -> None:
"""Show wrong configurations.""" """Show wrong configurations."""
if self.storage != "overlay2": if self.storage != "overlay2":