-
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 a few problems in 'podman logs --tail' with journald driver #12067
Fix a few problems in 'podman logs --tail' with journald driver #12067
Conversation
@hshiina thanks for the fixes! But looks like the podman logs tests are unhappy. |
fc16671
to
173b969
Compare
test/e2e/logs_test.go
Outdated
for _, log := range []string{"k8s-file", "journald", "json-file"} { | ||
|
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.
That is a good catch but the correct fix would be:
for _, log := range []string{"k8s-file", "journald", "json-file"} {
log := log
}
This allows us to have one loop and have the log driver in the test name.
Having this loop inside the It()
blocks would make it very hard to debug.
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.
Thank you for the advice!
@@ -121,7 +121,7 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption | |||
}() | |||
|
|||
tailQueue := []*logs.LogLine{} // needed for options.Tail | |||
doTail := options.Tail > 0 | |||
doTail := options.Tail >= 0 |
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.
I am sure this should stay Tail > 0
. If there are zero lines given we do not have to tail at all.
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 existing integration test expects '--tail 0' to output nothing and the other log drivers do so. I would like to make the journald driver consistent with the others now though this behavior may not be useful.
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.
OK, you are right. I thought the default value was 0 but it is -1.
df8c1f9
to
53adcd2
Compare
Changes LGTM. I'm on the fence about the |
53adcd2
to
2e73aaf
Compare
@@ -38,8 +51,16 @@ var _ = Describe("Podman logs", func() { | |||
}) | |||
|
|||
for _, log := range []string{"k8s-file", "journald", "json-file"} { | |||
log := log |
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.
Can you add a comment here explaining that this is important to move log var to the correct scope.
The following problems regarding `logs --tail` with the journald log driver are fixed: - One more line than a specified value is displayed. - '--tail 0' displays all lines while the other log drivers displays nothing. - Partial lines are not considered. - If the journald events backend is used and a container has exited, nothing is displayed. Integration tests that should have detected the bugs are also fixed. The tests are executed with json-file log driver three times without this fix. Signed-off-by: Hironori Shiina <[email protected]>
2e73aaf
to
c723e6b
Compare
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: hshiina, Luap99 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 |
@containers/podman-maintainers PTAL |
/lgtm |
/hold cancel |
Signed-off-by: Hironori Shiina [email protected]
What this PR does / why we need it:
The following problems regarding
logs --tail
with the journald log driver are fixed:--tail 0
displays all lines while the other log drivers displays nothing.Integration tests that should have detected the bugs are also fixed. The tests are executed with json-file log driver three times without this fix.
How to verify it
Run the fixed integration tests in
test/e2e/logs_test.go
.Which issue(s) this PR fixes:
None
Special notes for your reviewer: