Skip to content

libpod: correctly capture healthcheck output #23343

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

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Jul 19, 2024

Using the scanner is just unnecessary complicated an buggy as it will not read the final line with a newline. There is also the problem that it happens in a separate goroutine so it could loose output if we read the array before the scanner was done.

The API accepts a Writer so we can just directly use a bytes.Buffer which captures all output in memory without the need of another goroutine.

This also means that now we always include the final newline in the output. I checked with docker and they do the same so this is good.

Fixes #23332

Does this PR introduce a user-facing change?

Fixed a bug that resulted in the healtcheck output not being correctly captured when it didn't include a final newline.

Using the scanner is just unnecessary complicated an buggy as it will
not read the final line with a newline. There is also the problem that
it happens in a separate goroutine so it could loose output if we read
the array before the scanner was done.

The API accepts a Writer so we can just directly use a bytes.Buffer
which captures all output in memory without the need of another
goroutine.

This also means that now we always include the final newline in the
output. I checked with docker and they do the same so this is good.

Fixes containers#23332

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Copy link
Contributor

openshift-ci bot commented Jul 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /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 Jul 19, 2024
@mheon
Copy link
Member

mheon commented Jul 19, 2024

LGTM

@rhatdan
Copy link
Member

rhatdan commented Jul 22, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 22, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 249d042 into containers:main Jul 22, 2024
82 checks passed
@Luap99 Luap99 deleted the fix-hc-output branch July 22, 2024 12:34
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 21, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Oct 21, 2024
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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Healthcheck output not captured if missing newline
3 participants