mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 22:56:31 +00:00
Map both persistent and volatile journald logs (#2765)
* Map both persistent and volatile journald logs * Code comment tweak
This commit is contained in:
parent
c43acd50f4
commit
816e0d503a
@ -417,17 +417,16 @@ class DockerAddon(DockerInterface):
|
||||
|
||||
# System Journal access
|
||||
if self.addon.with_journald:
|
||||
# Systemd uses volatile by default, unless persistent location exists.
|
||||
journal = SYSTEMD_JOURNAL_VOLATILE
|
||||
if SYSTEMD_JOURNAL_PERSISTENT.exists():
|
||||
journal = SYSTEMD_JOURNAL_PERSISTENT
|
||||
|
||||
volumes.update(
|
||||
{
|
||||
str(journal): {
|
||||
str(SYSTEMD_JOURNAL_PERSISTENT): {
|
||||
"bind": str(SYSTEMD_JOURNAL_PERSISTENT),
|
||||
"mode": "ro",
|
||||
}
|
||||
},
|
||||
str(SYSTEMD_JOURNAL_VOLATILE): {
|
||||
"bind": str(SYSTEMD_JOURNAL_VOLATILE),
|
||||
"mode": "ro",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -97,36 +97,23 @@ def test_addon_map_folder_defaults(
|
||||
assert str(docker_addon.sys_config.path_extern_share) not in volumes
|
||||
|
||||
|
||||
def test_journald_addon_volatile(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
||||
"""Validate volume for journald option, with volatile logs."""
|
||||
with patch("pathlib.Path.exists", return_value=False):
|
||||
docker_addon = get_docker_addon(
|
||||
coresys, addonsdata_system, "journald-addon-config.json"
|
||||
)
|
||||
volumes = docker_addon.volumes
|
||||
|
||||
assert str(SYSTEMD_JOURNAL_VOLATILE) in volumes
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_VOLATILE)).get("bind") == str(
|
||||
SYSTEMD_JOURNAL_PERSISTENT
|
||||
def test_journald_addon(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
||||
"""Validate volume for journald option."""
|
||||
docker_addon = get_docker_addon(
|
||||
coresys, addonsdata_system, "journald-addon-config.json"
|
||||
)
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_VOLATILE)).get("mode") == "ro"
|
||||
|
||||
|
||||
def test_journald_addon_persistent(
|
||||
coresys: CoreSys, addonsdata_system: Dict[str, Data]
|
||||
):
|
||||
"""Validate volume for journald option, with persistent logs."""
|
||||
with patch("pathlib.Path.exists", return_value=True):
|
||||
docker_addon = get_docker_addon(
|
||||
coresys, addonsdata_system, "journald-addon-config.json"
|
||||
)
|
||||
volumes = docker_addon.volumes
|
||||
volumes = docker_addon.volumes
|
||||
|
||||
assert str(SYSTEMD_JOURNAL_PERSISTENT) in volumes
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_PERSISTENT)).get("bind") == str(
|
||||
SYSTEMD_JOURNAL_PERSISTENT
|
||||
)
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_PERSISTENT)).get("mode") == "ro"
|
||||
assert str(SYSTEMD_JOURNAL_VOLATILE) in volumes
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_VOLATILE)).get("bind") == str(
|
||||
SYSTEMD_JOURNAL_VOLATILE
|
||||
)
|
||||
assert volumes.get(str(SYSTEMD_JOURNAL_VOLATILE)).get("mode") == "ro"
|
||||
|
||||
|
||||
def test_not_journald_addon(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
||||
|
Loading…
x
Reference in New Issue
Block a user