Skip to content

Conversation

dano
Copy link
Contributor

@dano dano commented Jun 7, 2015

As described in issue #630, getting the stdout/stderr from tty-enabled containers doesn't work properly, because docker-py treats the output as multiplexed, when docker is actually sending a raw stream. This patch attempts to address this by determining if a container to is tty-enabled before trying to read its output, and if it is, read the raw stream, rather than reading at a multiplexed stream.

One piece here I'm not 100% sure about is what to do with the logic that was in attach to handle old API versions. The logic being used there - read the stream line by line, and skip empty new-lines, doesn't work if the container ever writes blank lines. I also haven't seen any keep-alive new lines being written in my testing, so I wonder if this check isn't really needed?

I suppose I could split _stream_raw_result into two methods - one for TTY-enabled containers, and one for versions below 1.6. The one for versions below 1.6 could keep the old, line-by-line behavior.

Also please let me know if any additional unit tests are needed.

@shin- shin- modified the milestone: 1.3.0 Jun 16, 2015
docker/client.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be replaced with just six.binary_type(), I believe.

@aanand
Copy link
Contributor

aanand commented Jul 1, 2015

I suppose I could split _stream_raw_result into two methods - one for TTY-enabled containers, and one for versions below 1.6. The one for versions below 1.6 could keep the old, line-by-line behavior.

Sounds sensible to me.

Also please let me know if any additional unit tests are needed.

I'm not sure I fully understand your changes to the tests. Are they now exclusively testing the Tty=True case? If so, we should make sure to also test the Tty=False case.

@dano
Copy link
Contributor Author

dano commented Jul 6, 2015

@aanand The tests currently don't actually specify a tty setting - the changes I made add a tty=False setting to the mocked container object used in each test, just to keep the tests from failing because container['Config']['Tty'] is missing. I'll look into adding a test for the tty=True case in addition to just keeping the existing tests working.

shin- and others added 23 commits July 6, 2015 18:04
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
- Add appropriate test which also asserts that volume names can be passed through to drivers.
- Add new param to docs.

Signed-off-by: Luke Marsden <luke@clusterhq.com>
as underlying exceptions(such as push already in progress) will be hidden in the stream generator otherwise.
This makes the build method consistent with the events method and adds
some convenience.
The boot2docker documentation has since changed the recommended way to
use shellinit - see boot2docker/boot2docker#786. The command also no
longer prints the export lines to the console, so have updated the
example output.
Volume binds now take a "mode" key, whose value can be any string.

"ro" is still supported. It is an error to specify both "ro" and "mode".

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This helps runtime introspection tools like the `help()` builting or
IPython's `?` operator correctly find the underlying method instead of
the decorator definition.
This makes docker-py consistent with Docker's newish way of establishing the path to .dockercfg:
   https://github.com/docker/docker/blob/master/pkg/homedir/homedir.go
The current map syntax does not allow the API equivalent of

    --add-host foo:1.1.1.1 --add-host foo:2.2.2.2

The above will map one hostname to two IPs.  The above is valid in Docker.
glogiotatidis and others added 20 commits July 6, 2015 18:06
This tries to load Docker authentication info from
~/.docker/config.json before falling back to its legacy location and
format at ~/.dockercfg.

Resolves docker#648
Treat output from TTY-enabled containers as raw streams, rather than
as multiplexed streams. The docker API docs specify that tty-enabled
containers don't multiplex. Also update tests to pass with these
changes, and changed the code used to read raw streams to not
read line-by-line, and to not skip empty lines.

Addresses issue docker#630

Signed-off-by: Dan O'Reilly <oreilldf@gmail.com>
@dano dano force-pushed the fix-tty-streams branch from 41a1ea3 to 27a158a Compare July 6, 2015 22:14
@dano
Copy link
Contributor Author

dano commented Jul 6, 2015

Ugh, it looks like my attempt to squash my commits ended up screwing up the branch completely. I'll open a new request...

@dano
Copy link
Contributor Author

dano commented Jul 6, 2015

Ok, I've opened #669 to replace this. It addresses all the comments from @aanand above. Apologies for the hassle of the new request.

@dano dano closed this Jul 6, 2015
@dano dano deleted the fix-tty-streams branch July 8, 2015 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.