Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coreos-printk-quiet.service: Lower kernel log level to 4 #1840

Merged
merged 1 commit into from Jul 15, 2022

Conversation

cgwalters
Copy link
Member

@cgwalters cgwalters commented Jul 13, 2022

Closes: coreos/fedora-coreos-tracker#1244

A lot going on for this simple service. See the tracker issue above
for more info, but briefly:

Anaconda has historically injected quiet into the kernel command
line in many cases, and this suppresses both kernel and systemd
output. On computers in general, but particularly many bare metal
servers, the serial console can be slow. This can cause reliability
issues.

However for servers, we usually do want to see informational
output when they boot. For example, today the kernel "mitigations"
information for hardware vulnerabilities is output.

This change is a compromise; we boot up at the kernel's default
verbosity level (which for Fedora and derivatives is the upstream 7),
but switch to 4 very early on in the real root. At that point, we've
gotten most of the boot time output, and our initramfs is not
extremely performance sensitive right now.

Also, we explicitly only lower the output log level, and only if
there isn't explicitly debug on the kernel command line.


@cgwalters
Copy link
Member Author

I do think this change though is most likely something that should actually happen Fedora wide. Upstreaming this module into dracut might be the easiest.

@lucab
Copy link
Contributor

lucab commented Jul 13, 2022

Out of curiosity, why did you decide against a sysctl.d entry in the real rootfs?

@cgwalters
Copy link
Member Author

I do think this change though is most likely something that should actually happen Fedora wide. Upstreaming this module into dracut might be the easiest.

Alternatively...changing https://src.fedoraproject.org/rpms/kernel/blob/rawhide/f/kernel-x86_64-fedora.config#_983 to 4 is likely the better way to do this.

@jlebon
Copy link
Member

jlebon commented Jul 13, 2022

Out of curiosity, why did you decide against a sysctl.d entry in the real rootfs?

Makes sense to me. It's also easier to disable via Ignition that way. And we'll want to do that for the kola devshell code since I think the state machine there relies on those to know e.g. when to SSH. (But also personally for --devshell-console, I'd just prefer to see everything.)

@cgwalters cgwalters changed the title Lower kernel log level to 4 before exiting initramfs coreos-printk-quiet.service: Lower kernel log level to 4 Jul 13, 2022
@cgwalters
Copy link
Member Author

OK 🆕 updated

  • Now runs very early in the real root, not initramfs
  • No-op if we detect kernel cmdline arguments quiet or debug
  • Change logic to always only lower debug output; so if someone e.g. explicitly configures the level to 2, we don't make things more verbose

@cgwalters
Copy link
Member Author

Also now updated to explicitly run Before=systemd-sysctl.service so that configuring printk via Ignition dropping a file in /etc/sysctl.d should still work.

jlebon
jlebon previously approved these changes Jul 13, 2022
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jlebon jlebon requested a review from bgilbert July 13, 2022 20:52
tests/kola/logging/printk.sh Outdated Show resolved Hide resolved
tests/kola/logging/printk.sh Outdated Show resolved Hide resolved
@@ -0,0 +1,24 @@
[Unit]
Description=CoreOS: Set printk to level 4 (warn)
Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/1244
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have proper FCOS docs for overriding this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously not opposed to documentation but...in the current design we honor all the standard Linux APIs for this in kernel arguments and injecting a sysctl.d file. The change of default is notable but it's close to a bugfix.

I think I'd say let's tackle documenting the printk level when we push to do this Fedora wide?

Closes: coreos/fedora-coreos-tracker#1244

A lot going on for this simple service.  See the tracker issue above
for more info, but briefly:

Anaconda has historically injected `quiet` into the kernel command
line in many cases, and this suppresses *both* kernel and systemd
output.  On computers in general, but particularly many bare metal
servers, the serial console can be slow.  This can cause reliability
issues.

However for servers, we usually *do* want to see informational
output when they boot.  For example, today the kernel "mitigations"
information for hardware vulnerabilities is output.

This change is a compromise; we boot up at the kernel's default
verbosity level (which for Fedora and derivatives is the upstream 7),
but switch to 4 very early on in the real root.  At that point, we've
gotten most of the boot time output, and our initramfs is not
extremely performance sensitive right now.

Also, we explicitly only *lower* the output log level, and only if
there isn't explicitly `debug` on the kernel command line.
@cgwalters
Copy link
Member Author

cgwalters commented Jul 15, 2022

Addressed all comments!

@cgwalters cgwalters merged commit 57395c7 into coreos:testing-devel Jul 15, 2022
cgwalters added a commit to cgwalters/fedora-coreos-docs that referenced this pull request Jul 28, 2022
cgwalters added a commit to cgwalters/fedora-coreos-docs that referenced this pull request Aug 17, 2022
dustymabe pushed a commit to coreos/fedora-coreos-docs that referenced this pull request Aug 18, 2022
jlebon added a commit to jlebon/fedora-coreos-config that referenced this pull request Feb 6, 2024
This doesn't work anymore since systemd locked down where generators
can write files:

    [    9.246494] /usr/lib/systemd/system-generators/coreos-liveiso-autologin-generator: line 24: /etc/sysctl.d/20-coreos-autologin-kernel-printk.conf: Read-only file system

But anyway, nowadays this duplicates `coreos-printk-quiet.service` which
was added two years after this code was written (coreos#1840).

Noticed by Colin in
ostreedev/ostree#3158 (comment).
dustymabe pushed a commit that referenced this pull request Feb 6, 2024
This doesn't work anymore since systemd locked down where generators
can write files:

    [    9.246494] /usr/lib/systemd/system-generators/coreos-liveiso-autologin-generator: line 24: /etc/sysctl.d/20-coreos-autologin-kernel-printk.conf: Read-only file system

But anyway, nowadays this duplicates `coreos-printk-quiet.service` which
was added two years after this code was written (#1840).

Noticed by Colin in
ostreedev/ostree#3158 (comment).
aaradhak pushed a commit to aaradhak/fedora-coreos-config that referenced this pull request Mar 18, 2024
This doesn't work anymore since systemd locked down where generators
can write files:

    [    9.246494] /usr/lib/systemd/system-generators/coreos-liveiso-autologin-generator: line 24: /etc/sysctl.d/20-coreos-autologin-kernel-printk.conf: Read-only file system

But anyway, nowadays this duplicates `coreos-printk-quiet.service` which
was added two years after this code was written (coreos#1840).

Noticed by Colin in
ostreedev/ostree#3158 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lower kernel printk level after boot
5 participants