Healthcheck output not captured if missing newline #23332
Labels
kind/bug
Categorizes issue or PR as related to a bug.
locked - please file new issue/PR
Assist humans wanting to comment on an old issue or PR with locked comments.
Issue Description
If the last line of the health check output is not terminated with a newline character it is not captured in the .State.Health.Log[].Output field.
This is a common scenario when using curl to test a REST API endpoint, Django REST Framework for example does not end the compact response in \n.
"hello" -> ""
"hello\n" -> "hello"
"hello\nworld" -> "hello"
"hello\nworld\n" -> "hello\nworld"
Workaround health-cmd:
/bin/sh -c 'curl -fs -A healthcheck/1.0 http://localhost:8080/api/v1/endpoint && echo'
Steps to reproduce the issue
Steps to reproduce the issue
$ podman run -it --rm --name hc-test --health-cmd 'printf "hello"' registry.access.redhat.com/ubi9/ubi read
$ podman inspect hc-test -f '{{json .State.Health}}' | python -m json.tool
Describe the results you received
Describe the results you expected
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
CentOS Stream 9, Podman 5.1.1 diff to 5.1.2 did not reveal anything that would fix this.
Additional information
If the health check is terminated by \n the output is successfully captured.
$ podman run -it --rm --name hc-test --health-cmd 'printf "hello\n"' registry.access.redhat.com/ubi9/ubi read
The text was updated successfully, but these errors were encountered: