-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix --tail log on restart problem #13857
Conversation
If it passes tests and doesn't bring back #12263, it's fine. |
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.
Mostly LGTM, with a few nits, and one big question: should the new test conform to the existing convention of testing under both k8s-file
and journald
?
Actually, two questions: regardless of the answer to the above, I think skip_if_journald_unavailable
might be needed to avoid the usual mad panic when this makes it into RHEL-land.
test/system/035-logs.bats
Outdated
@@ -30,6 +30,23 @@ load helpers | |||
run_podman rm $cid | |||
} | |||
|
|||
@test "podman logs - tail test" { | |||
rand_string=$(random_string 40) |
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.
unused
test/system/035-logs.bats
Outdated
run_podman restart $cid | ||
|
||
run_podman logs --tail 1 $cid | ||
is "$output" "test2" "logs should only show last line" |
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.
Could you rename this message? Maybe "logs, after restart, should still only show last line"? Distinct error messages make it sooooo much easier to track down the exact failure.
New push addresses two of my nits. Can you, for posterity, at least comment on my other questions? I don't know where we stand these days on rootless RHEL journald. |
I think we should test with both, if possible. |
I'm interpreting that as a request for code: function _log_test_tail() {
local driver=$1
run_podman run -d --log-driver=$driver $IMAGE sh -c "echo test1; echo test2"
cid="$output"
run_podman logs --tail 1 $cid
is "$output" "test2" "logs should only show last line"
run_podman restart $cid
run_podman logs --tail 1 $cid
is "$output" "test2" "logs should only show last line after restart"
run_podman rm $cid
}
@test "podman logs - tail test, k8s-file" {
_log_test_tail k8s-file
}
@test "podman logs - tail test, journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable
_log_test_tail journald
} |
--tail=1 is not working f you restart a container with journald logging. We see the exit status and then call into the logging a second time causing all of the logs to print. Removing the tail log on exited seems to fix the problem. Fixes: containers#13098 Signed-off-by: Daniel J Walsh <[email protected]>
@edsantiago Added your code. |
LGTM assuming tests pass. FYI I ran new tests against /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, rhatdan 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 |
/hold cancel |
--tail=1 is not working f you restart a container with journald logging.
We see the exit status and then call into the logging a second time
causing all of the logs to print.
Removing the tail log on exited seems to fix the problem.
Fixes: #13098
Signed-off-by: Daniel J Walsh [email protected]