From 0408998d968dab2546332cbebe30c7ead82ae8ce Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 7 Feb 2023 10:52:22 -0800 Subject: [PATCH] config: Drop RuntimeMaxUse=5% for journal logging Closes: #2313. systemd-journald does not (never did) accept size values given in percent of file system size. Only the defaults work with percent values. Hence our addition of RuntimeMaxUse= as percent value in configuration file did not work. systemd-journald outputs a warning to dmesg and ignores the value. We could change the value to fixed size. We would have to choose a value that works for systems with less memory (such as 1GiB) and that value would serve poorly for systems with more memory. Instead, leaving the default value of 10% for RuntimeMaxUse= might be better. Additional configuration of MaxFileSec=6h and MaxRetentionSec=2day would also ease the burden in most cases for the low memory devices. Considering that people did not report issues with status quo (where the value we have set did not work and default size was used) also suggests that default value will work. Further, /run filesystem itself seems to be allocated only 10% of available memory. Tests: - Without the patch, start a vagrant machine. Notice that dmesg shows the error mentioned in the issue #2313. Apply patch and restart the service. Setup is run for config app. The file /etc/systemd/journald.conf.d/50-freedombox.conf will no longer have the RuntimeMaxUse= directive. - After reboot, dmesg will no longer show the error. systemctl status systemd-journald shows that 10% of the size of /run is the max for journal file. - In config app page, setting various values of log persistence works. - On a fresh container with the patch, initial setup succeeds and journald.conf.d file is setup without the RuntimeMaxUse= directive. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/config/__init__.py | 4 +++- plinth/modules/config/privileged.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index c2ebd046a..293168da2 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -31,7 +31,7 @@ class ConfigApp(app_module.App): app_id = 'config' - _version = 4 + _version = 5 can_be_disabled = False @@ -79,6 +79,8 @@ class ConfigApp(app_module.App): if old_version <= 3: privileged.set_logging_mode('volatile') + elif old_version == 4: + privileged.set_logging_mode(privileged.get_logging_mode()) # systemd-journald is socket activated, it may not be running and it # does not support reload. diff --git a/plinth/modules/config/privileged.py b/plinth/modules/config/privileged.py index 24d38de49..ad5b7f58d 100644 --- a/plinth/modules/config/privileged.py +++ b/plinth/modules/config/privileged.py @@ -85,14 +85,13 @@ def set_logging_mode(mode: str): aug = load_augeas() aug.set('Journal/Storage', mode) if mode == 'volatile': - aug.set('Journal/RuntimeMaxUse', '5%') aug.set('Journal/MaxFileSec', '6h') aug.set('Journal/MaxRetentionSec', '2day') else: - aug.remove('Journal/RuntimeMaxUse') aug.remove('Journal/MaxFileSec') aug.remove('Journal/MaxRetentionSec') + aug.remove('Journal/RuntimeMaxUse') JOURNALD_FILE.parent.mkdir(exist_ok=True) aug.save()