-
Notifications
You must be signed in to change notification settings - Fork 2.7k
System tests: Update the journalctl function to ignore No entry message #26575
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
Conversation
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
2119a60
to
94fd8a6
Compare
/release-note-none |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For currently version of journalctl, --user option only works when the persistent storage is enabled.
Do you have some docs for that? Because first of all my system uses Storage=auto which also works. In general config checks like that are a bad idea because systemd might change the behaviours. It is best to do a proper feature check.
Also why does --user-unit
work but --user
doesn't? I am a bit confused why you can read the system log but not the per user logs.
test/system/helpers.systemd.bash
Outdated
@@ -14,12 +14,44 @@ fi | |||
|
|||
mkdir -p $UNIT_DIR | |||
|
|||
journalctl_support_user() { | |||
r_value=0 | |||
run systemd-analyze cat-config systemd/journald.conf | grep Storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pipe does not capture output here at all. $output is set by the run function and that does not output to stdout by default so the pipe cannot work.
test/system/helpers.systemd.bash
Outdated
if [[ "$output" == "Storage=persistent" ]]; then | ||
r_value=1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you actually have a drop in file cat-config prints all file outputs while this only catches one, so I am not sure this is is even correct.
I would suggest you do a proper function test instead by checking if journalctl --user returns logs and laso the result should be cached so we don't always run this command over and over again.
Lastly isn't this just inverse of what you are saying, 0 return should mean success but you return 1 instead which is super confusing for any caller.
test/system/helpers.systemd.bash
Outdated
systemctl() { | ||
timeout --foreground -v --kill=10 $PODMAN_TIMEOUT systemctl $_DASHUSER "$@" | ||
} | ||
|
||
journalctl() { | ||
timeout --foreground -v --kill=10 $PODMAN_TIMEOUT journalctl $_DASHUSER "$@" | ||
if is_rootless and ! journalctl_support_user; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to use &&
and not and
, it would be news to me that and
is accepted by bash and from a quick test it doesn't work for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your reviewing. I am a little mess up with shell and python. And just test it with Fedora and RHEL 9.6 with should go to the if branch and didn’t find the problem in the code. Now the code is updated. Should work as expected.
I still think checking the config file is the wrong approach, the default uses auto which also works fine. Your code cannot handle drop in files correctly either. Would it not be much simpler to run something like Or maybe we should ask a different question. Is there any reason to use --user at all then if --user-unit works better? Could we not just use this all the time instead of complicating the code. |
Hi @Luap99 Thanks for your reviewing. Actually this is found in our gating tests for 9.6. And I found this from the journactl man page:
` And the systemd-analyze cat-config command is also pick from the journald.conf ‘s comments.
|
Just double confirmed that the journalctl --user actually works in Fedora even when the journald.conf is not set to any value. This may related with the systemd version in the system. Although this code will not failed, but will try to update the function for the support check. |
Hi @Luap99
Test it with case “quadlet - basic” with both Fedora and RHEL 9.6 and test cases are passed in both host. Can you help to review this again? Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just small things but this is what I had in mind, thanks.
For currently version of journalctl, --user option only works when the persistent storage is enabled. So we need to check this option before we use it. Otherwise a set of tests will failed with can not find expected output from journalctl with rootless user. Signed-off-by: Yiqiao Pu <ypu@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Luap99, ypu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM Tested on my system where I could reproduce the issue without patch and it works correctly with patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
For currently version of journalctl, --user option only works when the persistent storage is enabled. So we need to check this option before we use it. Otherwise a set of tests will failed with can not find expected output from journalctl with rootless user.
Does this PR introduce a user-facing change?