-
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
podman logs -f ends early #10596
Comments
Thanks for opening the issue, @Hendrik-H! Can you run |
|
I opened #10600 to fix the issue. |
Fix a race in the k8s-file logs driver. When "following" the logs, Podman will print the container's logs until the end. Previously, Podman logged until the state transitioned into something non-running which opened up a race with the container still running, possibly in the "stopping" state. To fix the race, log until we've seen the wait event for the specific container. In that case, conmon will have finished writing all logs to the file, and Podman will read it until EOF. Further tweak the integration tests for testing `logs -f` on a running container. Previously, the test only checked for one of two lines stating that there was a race. Indeed the race was in using `run --rm` where a log file may be removed before we could fully read it. Fixes: containers#10596 Signed-off-by: Valentin Rothberg <[email protected]>
@Hendrik-H, note that there's an inherent race when using AFAIKS, the log file may get removed before we could fully read it. @mheon do you think it's sad fact of life or shall we tackle it one way or another? |
@vrothberg thanks for the tip and the quick fix |
@vrothberg It might get removed, but we'll still have an open file descriptor, no? I don't think we can do this another way, this is in the c/storage directories and if we don't remove it removing the storage container will fail. |
Probably. I had to dig deeper on how things like inotify might be used. One odd thing is that journald also flakes/d with |
Fix a race in the k8s-file logs driver. When "following" the logs, Podman will print the container's logs until the end. Previously, Podman logged until the state transitioned into something non-running which opened up a race with the container still running, possibly in the "stopping" state. To fix the race, log until we've seen the wait event for the specific container. In that case, conmon will have finished writing all logs to the file, and Podman will read it until EOF. Further tweak the integration tests for testing `logs -f` on a running container. Previously, the test only checked for one of two lines stating that there was a race. Indeed the race was in using `run --rm` where a log file may be removed before we could fully read it. Fixes: containers#10596 Signed-off-by: Valentin Rothberg <[email protected]>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
A container traps SIGINT and SIGTERM, logs a few things, waits a few seconds, logs more and then exits. A parallel
podman logs -f ...
for that container does not capture all the logs and ends early when the container is stopped usingpodman stop
. I believe I also had a case that a bit was missing when stopping withctrl-c
but I can not reproduce that anymore.Test Dockerfile:
FROM fedora:34 ADD script.sh / ENTRYPOINT ["/script.sh"]
Test Script:
Steps to reproduce the issue:
podman build -t=podman-test .
podman run -it --name test --rm podman-test
podman logs -f test
podman stop --time 10 test
Describe the results you received:
When using
podman stop
the logs stop straight away in thepodman logs -f
terminal and some logs that are still coming out in thepodman run
terminal are missing. When you try to restartpodman logs -f
while the container is in thestopping
state you can not follow the logs anymore.Describe the results you expected:
podman logs -f
to log out all logs until the container is fully stopped and not just until it is starting to stop.Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)
No
Additional environment details (AWS, VirtualBox, physical, etc.):
laptop
The text was updated successfully, but these errors were encountered: