mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +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
|
# System Journal access
|
||||||
if self.addon.with_journald:
|
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(
|
volumes.update(
|
||||||
{
|
{
|
||||||
str(journal): {
|
str(SYSTEMD_JOURNAL_PERSISTENT): {
|
||||||
"bind": str(SYSTEMD_JOURNAL_PERSISTENT),
|
"bind": str(SYSTEMD_JOURNAL_PERSISTENT),
|
||||||
"mode": "ro",
|
"mode": "ro",
|
||||||
}
|
},
|
||||||
|
str(SYSTEMD_JOURNAL_VOLATILE): {
|
||||||
|
"bind": str(SYSTEMD_JOURNAL_VOLATILE),
|
||||||
|
"mode": "ro",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,26 +97,8 @@ def test_addon_map_folder_defaults(
|
|||||||
assert str(docker_addon.sys_config.path_extern_share) not in volumes
|
assert str(docker_addon.sys_config.path_extern_share) not in volumes
|
||||||
|
|
||||||
|
|
||||||
def test_journald_addon_volatile(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
def test_journald_addon(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
||||||
"""Validate volume for journald option, with volatile logs."""
|
"""Validate volume for journald option."""
|
||||||
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
|
|
||||||
)
|
|
||||||
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(
|
docker_addon = get_docker_addon(
|
||||||
coresys, addonsdata_system, "journald-addon-config.json"
|
coresys, addonsdata_system, "journald-addon-config.json"
|
||||||
)
|
)
|
||||||
@ -127,6 +109,11 @@ def test_journald_addon_persistent(
|
|||||||
SYSTEMD_JOURNAL_PERSISTENT
|
SYSTEMD_JOURNAL_PERSISTENT
|
||||||
)
|
)
|
||||||
assert volumes.get(str(SYSTEMD_JOURNAL_PERSISTENT)).get("mode") == "ro"
|
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]):
|
def test_not_journald_addon(coresys: CoreSys, addonsdata_system: Dict[str, Data]):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user