-
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
[APIv2] Container log not provided #7196
Comments
@ashley-cui PTAL |
https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_logs.go#L139
|
timestamps does not make any difference in my case, output is empty ( no matter whether rootless or rootfull ) |
I found the reason,
build with
now get the container's ID, open another terminal. and run this
You can see that there is a problem with the log-writing logic. and I update runc, it still exsit. and I can't find where the code was written to the log file
|
Leaving aside other issues this line is probably wrong https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_logs.go#L88 |
The source of the error is not here, and the log source returned by the API is also read from the container log file |
@zhangguanzhang One more question - according to docker api doc https://docs.docker.com/engine/api/v1.40/#operation/ContainerAttach
Given that should be the output header written always ? https://github.com/containers/podman/blob/master/pkg/api/handlers/compat/containers_logs.go#L141 |
problem is not in the api handler,you could see this
and this
enabled |
Are you sure ? I think that in case tty is enabled then the downloaded log should not contain the output header - those "invisible characters" as you call them |
The logs are written by Conmon - https://github.com/containers/conmon/ |
@zhangguanzhang looks like you were right on this issue, seems to be libpod not reading log lines correctly. Thanks for pointing it out, but it's strange since it affects the remote api but not the cli in outputting the log. if you have any ideas, let me know |
Up to now, I have not found any clues about the occurrence of the problem |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Container log not provided
Steps to reproduce the issue:
Docker
CLI
docker create --interactive --tty --name busybox docker.io/library/busybox:latest sh -c "echo Hello"
docker start busybox
docker logs busybox
docker inspect busybox > /tmp/test-busybox-docker.txt
docker rm busybox
REST
curl --unix-socket /var/run/docker.sock -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/create?name=busybox' --data '{"name":"busybox2","Image":"docker.io/library/busybox:latest", "Tty":true, "Cmd":["sh", "-c", "echo Hello"]}'
curl --unix-socket /var/run/docker.sock -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/busybox/start'
curl --unix-socket /var/run/docker.sock --output - -H "Content-Type: application/json" "http://127.0.0.1:8880/containers/busybox/logs?stdout=true&stderr=true"
docker logs busybox
docker inspect busybox > /tmp/test-busybox-docker-api.txt
curl --unix-socket /var/run/docker.sock -X DELETE -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/busybox'
Podman
podman --log-level=debug system service -t 0 tcp:localhost:8880 2>&1>/tmp/podman-rest.log &
CLI
podman create --interactive --tty --name busybox docker.io/library/busybox:latest sh -c "echo Hello"
podman start busybox
podman logs busybox
podman inspect busybox > /tmp/test-busybox-podman.txt
podman rm busybox
REST
curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/create?name=busybox' --data '{"name":"busybox2","Image":"docker.io/library/busybox:latest", "Tty":true, "Cmd":["sh", "-c", "echo Hello"]}'
curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/busybox/start'
curl --output - -H "Content-Type: application/json" "http://127.0.0.1:8880/containers/busybox/logs?stdout=true&stderr=true"
podman logs busybox
podman inspect busybox > /tmp/test-busybox-podman-api.txt
curl -X DELETE -H "Content-Type: application/json" 'http://127.0.0.1:8880/containers/busybox'
Describe the results you received:
returns Hello
returns nothing
returns Hello
Describe the results you expected:
All three commands above should return Hello
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
):Additional environment details (AWS, VirtualBox, physical, etc.):
physical
The text was updated successfully, but these errors were encountered: