Bug 15678 - Systemd disables creation of /var/log/journal and related directories
Summary: Systemd disables creation of /var/log/journal and related directories
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 5.0.5
Hardware: All Multiple
: Medium+ minor
Target Milestone: 5.2 M2
Assignee: Changqing Li
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-12-03 16:52 UTC by Steffen Kothe
Modified: 2025-02-06 01:22 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Suggestion for systemd upstream fix when bug is confirmed in Yocto (1.59 KB, patch)
2024-12-03 16:52 UTC, Steffen Kothe
no flags Details | Diff
enable create-log-dirs (1.61 KB, patch)
2024-12-12 10:24 UTC, Changqing Li
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Kothe 2024-12-03 16:52:54 UTC
Created attachment 5086 [details]
Suggestion for systemd upstream fix when bug is confirmed in Yocto

18d46e11d85d ("systemd: fix dead link /var/log/README")

Disabled the build time creation of the /var/log/journal directories in favor of keeping a README which is mostly irrelevant for most embedded Linux systems, usually not shipping documentation. 

Additionally does this "fix" change the behavior of VOLATILE_LOG_DIR, since logs are not persistently stored anymore, because systemd does not recreate the directory structure during boot via systemd-tmpfiles.d.

While non-persistent logs are not getting affected by this change does it affect the persistent storing of logs. They are lost, so it can be assumed that the mentioned fixed introduced a bug when VOLATILE_LOG_DIR = "1" is set.

Recommendation/counter measure:

Revert this commit and drop the suspicious README link from the legacy configuration file via sed script or patch.

A patch is attached, which was not sent upstream yet to re-enable.

A contribution with a fix is intended to be sent when the bug is confirmed.
Comment 1 Randy MacLeod 2024-12-05 15:37:28 UTC
Sandy/Changqing, Did you or someone else in the WR team change this?
Can someone take a look, please. 
Nico may be involved, I don't have time to check right now, sorry.
Comment 2 Changqing Li 2024-12-06 04:38:38 UTC
@steffen, @Randy

Please refer this V1 patch comments and V5 patch comments:
https://patchwork.yoctoproject.org/project/oe-core/patch/20230629101038.3772750-1-changqing.li@windriver.com/
https://patchwork.yoctoproject.org/project/oe-core/patch/20240227051155.2166683-1-changqing.li@windriver.com/

And then finally we have this commit:
18d46e11d85d ("systemd: fix dead link /var/log/README")


The attached patch is the same as the V1 patch.
Comment 3 Steffen Kothe 2024-12-09 17:49:37 UTC
Circumventing this issue for creating the /var/log/journal can be done by configuring journald.conf to make the storage persistent.

See Options, "Storage" in https://man7.org/linux/man-pages/man5/journald.conf.5.html

Wouldn't it be an idea then to couple VOLATILE_LOG_DIR to this configuration additionally to the V5 patch posted.

This is exactly what breaks here due to a README which seems to be part of the doc package anyway or am I wrong?

Happy to contribute here.


Meanwhile - create-log-dirs also affects the journald companions systemd-journal-remote and gatewayd.

This directory is also created by this flag during built time.
Comment 4 Changqing Li 2024-12-12 10:23:04 UTC
There is behavior change after disabling create-log-dirs:

when create-log-dirs is enabled,  /var/log/journal will be created, and since "Storage" in journald.conf is default "Auto", when it defects exist of "/var/log/journal", then log will be storge under /var/log/journal.  And this is recipe level.  And if /var/log/journal is really persistent,  it is decided by the distro level config, now it is named as "FILESYSTEM_PERMS_TABLES" now. user only need to change FILESYSTEM_PERMS_TABLES to make systemd log persistent


after create-log-dirs is disabled,  /var/log/journal is not created,  and since "Storage" in journald.conf is default "Auto",  since /var/log/journal not exist,
/run/log/journal will be used to store log. which is not persistent. if user want persistent log,  they need to change "Storage" to "persistent" in journald.conf, then /var/log/journal will be created to store log. Then distro level config "FILESYSTEM_PERMS_TABLES" will decide if it is a really persistent. 



This cause user have to do extra change of journald.conf to make log persistent.
and maybe we should make the behavior back? For the README issue, since this README is not very useful, maybe we can just don't create it, Attached the RFC patch.


@Richard, @Khem,  what's your opinion?
Comment 5 Changqing Li 2024-12-12 10:24:05 UTC
Created attachment 5087 [details]
enable create-log-dirs
Comment 6 Steffen Kothe 2024-12-12 12:00:08 UTC
There was a discussion about the systemd-doc packages which suggested to keep the README there.

Having a link for no reason makes no sense, so dropping it seems to be okay.

This restores the creation of the directories anyway and even leaves, if required, the generation of journald associated packages and its users intact.
Comment 7 Changqing Li 2025-02-06 01:17:44 UTC
enable create-log-dirs in this commit:
https://git.openembedded.org/openembedded-core/commit/?id=f82d9c997ba8cc23b472d44a43489c597bf452af
Comment 8 Changqing Li 2025-02-06 01:22:54 UTC
enable create-log-dirs in this commit:
https://git.openembedded.org/openembedded-core/commit/?id=f82d9c997ba8cc23b472d44a43489c597bf452af