Skip to content

Fix a few problems in 'podman logs --tail' with journald driver - #12067

Merged
openshift-merge-robot merged 1 commit into
podman-container-tools:mainfrom
hshiina:logs-journal-tail
Oct 26, 2021
Merged

Fix a few problems in 'podman logs --tail' with journald driver#12067
openshift-merge-robot merged 1 commit into
podman-container-tools:mainfrom
hshiina:logs-journal-tail

Conversation

@hshiina

@hshiina hshiina commented Oct 23, 2021

Copy link
Copy Markdown
Contributor

Signed-off-by: Hironori Shiina shiina.hironori@jp.fujitsu.com

What this PR does / why we need it:

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.

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:

@umohnani8

Copy link
Copy Markdown
Contributor

@hshiina thanks for the fixes! But looks like the podman logs tests are unhappy.

Comment thread test/e2e/logs_test.go Outdated
Comment on lines 40 to 41

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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!

Comment thread libpod/container_log_linux.go Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

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.

@hshiina
hshiina force-pushed the logs-journal-tail branch 2 times, most recently from df8c1f9 to 53adcd2 Compare October 25, 2021 21:57
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

Changes LGTM. I'm on the fence about the > vs >= discussion.

Comment thread test/e2e/logs_test.go Outdated

Copy link
Copy Markdown
Member

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 <shiina.hironori@jp.fujitsu.com>

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@openshift-ci

openshift-ci Bot commented Oct 26, 2021

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2021
@Luap99

Luap99 commented Oct 26, 2021

Copy link
Copy Markdown
Member

@containers/podman-maintainers PTAL

@rhatdan

rhatdan commented Oct 26, 2021

Copy link
Copy Markdown
Contributor

/lgtm
/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2021
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 26, 2021
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 26, 2021
@openshift-merge-robot
openshift-merge-robot merged commit 1243954 into podman-container-tools:main Oct 26, 2021
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants