Fix stdout premature EOF#8571
Conversation
There was a problem hiding this comment.
@LK4D4 didn't you already change this to use logs?
|
Do you all generally prefer the nJobs for loop that currently exists in master, or the 2 "done" booleans with the break statement? |
|
Actually, scratch that, since we have to wait for stdout and stderr to finish before we can close stdin |
d188761 to
8fc8703
Compare
|
@ncdc I'm slightly in favor of keeping the nJobs loop but like the removal of |
|
Oh, that won't work as-is, because if you do it will hang waiting for the stdin job to complete. If you hit enter, it will finish and return you to the host's shell. I think we need to finish attach when either all 3 jobs have finished, or both stdout and stderr have finished, whichever happens first. Something more like this: https://github.com/ncdc/docker/compare/3631-stdout-premature-eof-njobs-2 |
There was a problem hiding this comment.
This all stuff seems to be in different goroutines, so this code is racy, probably you should use channels for this notifications.
There was a problem hiding this comment.
Thanks, I'll work on it tomorrow.
There was a problem hiding this comment.
There was a problem hiding this comment.
Now better, so you want to save nJobs idea? I think it will be better to just write stdout job finished or something like this. Maybe in addition to number...
There was a problem hiding this comment.
I'm fine getting rid of nJobs if everyone is ok with that.
There was a problem hiding this comment.
Yeah, let's ask someone. ping @jfrazelle @erikh
There was a problem hiding this comment.
|
@ncdc Can you explain the bash regression you were having with the previous version a bit more. I don't see any differences compared to edit: also, just to be clear, what branch were you talking about? |
|
@tonistiigi that was just from me fiddling around with nJobs. If all you do is get rid of the stdinCloser logic, the stdin job won't complete until the client closes its end of the stream, which happens when you hit enter after attempting to exit from the shell. If the client opens stdin, the engine needs to close its half of the stdin stream when stdout and stderr finish. |
|
@tonistiigi and for clarity, the "regression" was in my branch |
|
@ncdc ok, I though this was in Looking at |
|
@ncdc Would you mind to post your branch here? |
|
@LK4D4 I'm currently attempting to write an integration test that fails with master but is fixed with my branch. I also think @tonistiigi might be on to something simpler - we maybe can just remove the |
|
Okay, keep us updated! |
|
@LK4D4 this is the best I've been able to come up with so far for an integration test. I was hoping to imitate func TestAttachSlowConsumer(t *testing.T) {
defer deleteAllContainers()
c := exec.Command("/bin/bash", "-c", "echo | "+dockerBinary+` run --rm -i busybox /bin/sh -c "dd if=/dev/zero of=/foo bs=1024 count=2000 &>/dev/null; catv /foo" | /bin/bash -c "sleep 2; wc -c"`)
output, err := c.Output()
if err != nil {
t.Fatal(err)
}
// assert that output == 2*1024*2000
logDone("attach - slow consumer")
} |
|
I remember that @tibor wrote something cool with |
|
I obviously don't like the Also, once this issue is fixed, we won't exactly be able to wait for a "stream closed" error... |
8fc8703 to
ab2e935
Compare
|
@LK4D4 @tonistiigi PR updated, please see latest diffs. |
Never close attached stream before both stdout and stderr have written all their buffered contents. Remove stdinCloser because it is not needed any more as the stream is closed anyway after attach has finished. Fixes moby#3631 Signed-off-by: Andy Goldstein <[email protected]>
ab2e935 to
5572dbb
Compare
|
@ncdc LGTM |
|
Very good indeed! |
|
@LK4D4 do we need other reviews so this can hopefully be merged in? |
|
LGTM |
Never close attached stream before both stdout and stderr have written
all their buffered contents. Remove stdinCloser because it is not needed
any more as the stream is closed anyway after attach has finished.
Fixes #3631
Signed-off-by: Andy Goldstein [email protected]