-
Notifications
You must be signed in to change notification settings - Fork 134
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
container exits but output stream remains open #251
Comments
So, with the However, I've just merged a PR that should change that behaviour #250 - in the latest master, streams that return an error in the JSON will also return an error in Bollard. Let me know in your testing if that works for you. |
To clarify, the issue that I am seeing is not with the The context is that the project in question is a build tool that needs to capture all output from running a build action in a Docker container. I observed a race condition in testing where my code would fail to capture some output. My thought was to check the Regarding #250, I will try it out with the hope that maybe that it will change the behavior of the |
I tried the latest |
I'm having similar issues - or so I think, at least. I may have a repro case too, one that isn't particularly big, either. I have to clean it up a little first, it's in a private repo at the moment, have to lift it out of there. |
Ok, thanks for explaining a bit. That does sound quite different. I would appreciate a minimal test case -- @antoinert do you have any idea why this might be happening? |
#254 has a minimal reproduction. |
Thanks for the reduced example. I took a quick look, and can confirm that the streams are hanging. Some playing around though confirmed there is a timing issue with the running container and the client that attaches the output. If you change the I'll be taking a closer look at the hyper logs to see if there's something else I can see. |
For my own use case, I ended up using executions (which return the output stream), and so this issue is not an issue for me any more. I can close unless someone else has a reason to keep it open. In any event, it seems like the proper way to attach to a container would be to call |
Let's keep the ticket open. I tried comparing the hyper / tokio logs between the two, but didn't see anything of notice. The server should have the responsibility of closing the stream, so it should be reproducible on the moby codebase - that's my next step regarding this ticket. |
I have done some more due diligence to this issue to try and understand what is going on, and replicated the example PR using the golang moby client SDK: https://github.com/moby/moby/compare/master...fussybeaver:moby:ND-attach-ordering-issue?expand=1 One thing struck me initially - removing the As demonstrated in this ticket (and in this closed moby ticket), the intended useage of the API is Similarly in Bollard, I assume that a stream will only close when a container is stopped. We should probably change the documentation to make this point clear when using this API. I'm open to any suggestions though on making this more ergonomic. |
I am trying to capture output from a running container using
Docker::attach_container
but it appears that the output stream does not close even though the container exited (and which was reported via thewait_container
stream). The code at issue is in this PR pantsbuild/pants#16766.That code monitors the output stream returned by
attach_container
and the stream fromwait_container
for the exit code with atokio::select!
. When the container exits, the code breaks out of the monitoring loop and then tries to see if any output remains on the output stream, but that stream never closes so the code hangs there.Am I somehow not using the APIs correctly? (The machine is macOS 12.5.1 with Docker Desktop 4.11.1.)
The text was updated successfully, but these errors were encountered: