mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-24 09:36:31 +00:00
Verify the cgroup supported level (#3688)
* Verify the cgroup supported level * add tests
This commit is contained in:
parent
b001aa882a
commit
1f69cf0fe6
@ -50,12 +50,16 @@ class DockerInfo:
|
||||
version: AwesomeVersion = attr.ib()
|
||||
storage: str = attr.ib()
|
||||
logging: str = attr.ib()
|
||||
cgroup: str = attr.ib()
|
||||
|
||||
@staticmethod
|
||||
def new(data: dict[str, Any]):
|
||||
"""Create a object from docker info."""
|
||||
return DockerInfo(
|
||||
AwesomeVersion(data["ServerVersion"]), data["Driver"], data["LoggingDriver"]
|
||||
AwesomeVersion(data["ServerVersion"]),
|
||||
data["Driver"],
|
||||
data["LoggingDriver"],
|
||||
data["CgroupVersion"],
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -8,6 +8,7 @@ from .base import EvaluateBase
|
||||
|
||||
EXPECTED_LOGGING = "journald"
|
||||
EXPECTED_STORAGE = "overlay2"
|
||||
EXPECTED_CGROUP_VERSION = "1"
|
||||
|
||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||
|
||||
@ -37,13 +38,27 @@ class EvaluateDockerConfiguration(EvaluateBase):
|
||||
|
||||
async def evaluate(self):
|
||||
"""Run evaluation."""
|
||||
_storage = self.sys_docker.info.storage
|
||||
_logging = self.sys_docker.info.logging
|
||||
storage_driver = self.sys_docker.info.storage
|
||||
logging_driver = self.sys_docker.info.logging
|
||||
cgroup_version = self.sys_docker.info.cgroup
|
||||
|
||||
if _storage != EXPECTED_STORAGE:
|
||||
_LOGGER.warning("Docker storage driver %s is not supported!", _storage)
|
||||
if storage_driver != EXPECTED_STORAGE:
|
||||
_LOGGER.warning(
|
||||
"Docker storage driver %s is not supported!", storage_driver
|
||||
)
|
||||
|
||||
if _logging != EXPECTED_LOGGING:
|
||||
_LOGGER.warning("Docker logging driver %s is not supported!", _logging)
|
||||
if logging_driver != EXPECTED_LOGGING:
|
||||
_LOGGER.warning(
|
||||
"Docker logging driver %s is not supported!", logging_driver
|
||||
)
|
||||
|
||||
return _storage != EXPECTED_STORAGE or _logging != EXPECTED_LOGGING
|
||||
if cgroup_version != EXPECTED_CGROUP_VERSION:
|
||||
_LOGGER.warning(
|
||||
"Docker cgroup version %s is not supported!", cgroup_version
|
||||
)
|
||||
|
||||
return (
|
||||
storage_driver != EXPECTED_STORAGE
|
||||
or logging_driver != EXPECTED_LOGGING
|
||||
or cgroup_version != EXPECTED_CGROUP_VERSION
|
||||
)
|
||||
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
||||
from supervisor.const import CoreState
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.resolution.evaluations.docker_configuration import (
|
||||
EXPECTED_CGROUP_VERSION,
|
||||
EXPECTED_LOGGING,
|
||||
EXPECTED_STORAGE,
|
||||
EvaluateDockerConfiguration,
|
||||
@ -20,18 +21,28 @@ async def test_evaluation(coresys: CoreSys):
|
||||
|
||||
coresys.docker.info.storage = "unsupported"
|
||||
coresys.docker.info.logging = EXPECTED_LOGGING
|
||||
coresys.docker.info.cgroup = EXPECTED_CGROUP_VERSION
|
||||
await docker_configuration()
|
||||
assert docker_configuration.reason in coresys.resolution.unsupported
|
||||
coresys.resolution.unsupported.clear()
|
||||
|
||||
coresys.docker.info.storage = EXPECTED_STORAGE
|
||||
coresys.docker.info.logging = "unsupported"
|
||||
coresys.docker.info.cgroup = EXPECTED_CGROUP_VERSION
|
||||
await docker_configuration()
|
||||
assert docker_configuration.reason in coresys.resolution.unsupported
|
||||
coresys.resolution.unsupported.clear()
|
||||
|
||||
coresys.docker.info.storage = EXPECTED_STORAGE
|
||||
coresys.docker.info.logging = EXPECTED_LOGGING
|
||||
coresys.docker.info.cgroup = "unsupported"
|
||||
await docker_configuration()
|
||||
assert docker_configuration.reason in coresys.resolution.unsupported
|
||||
coresys.resolution.unsupported.clear()
|
||||
|
||||
coresys.docker.info.storage = EXPECTED_STORAGE
|
||||
coresys.docker.info.logging = EXPECTED_LOGGING
|
||||
coresys.docker.info.cgroup = EXPECTED_CGROUP_VERSION
|
||||
await docker_configuration()
|
||||
assert docker_configuration.reason not in coresys.resolution.unsupported
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user