quadlet: only log to kmsg when running under systemd#28898
Open
mvanhorn wants to merge 2 commits into
Open
Conversation
Luap99
requested changes
Jun 10, 2026
| line := fmt.Sprintf("quadlet-generator[%d]: %s", os.Getpid(), s) | ||
|
|
||
| if !logToKmsg(line) || dryRunFlag { | ||
| stderrIsTerminal := term.IsTerminal(int(os.Stderr.Fd())) |
Member
There was a problem hiding this comment.
That is wrong though, there is not requirement whatsoever that someone running quadlet to debug things should have a tty on stderr, in fact someone might want to pipe the output to a file
IF we want to check if we run under systemd there seem to be some env vars documented we could check https://www.freedesktop.org/software/systemd/man/latest/systemd.generator.html#Environment
but even then I would guess systemd-analyze --generators verify might set the same so they cannot be used to know that either?
In any case it seems simplest and safest to just log to both.
When the quadlet generator is run manually from a terminal, warnings and errors were written to /dev/kmsg, polluting the kernel log. Write to stderr for interactive runs and keep the kmsg path for systemd invocations (no tty), preserving the existing fallback behavior. Fixes: podman-container-tools#28888 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
a6f1c31 to
9ec4699
Compare
…enerator-kmsg-logging
alexlarsson
reviewed
Jun 11, 2026
|
|
||
| if !logToKmsg(line) || dryRunFlag { | ||
| stderrIsTerminal := term.IsTerminal(int(os.Stderr.Fd())) | ||
| kmsgOK := false |
Contributor
There was a problem hiding this comment.
Maybe we should just never log to kmesg if euid != 0.
Contributor
Author
|
/packit retest-failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)gofmtandgo vet(make validateprneeds a containerized environment not available locally; CI runs the full validation)Noneif no user-facing changes)Does this PR introduce a user-facing change?
Fixes #28888