docker / docker/docker-py

docker.from_env blocks with paramiko on python2.7

Open
#2,359 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

The code below block always reproduces with python2.7 on MacOS when DOCKER_HOST=ssh://somehost. The same code works fine with on other python versions and I also tested with latest paramiko==2.5.0. This seems to be related to an ancient paramiko ticket at https://github.com/paramiko/paramiko/issues/109 which could be avoided based on few comments I read there.

exitstatus: 2
    client = docker.from_env(timeout=5, version="auto")
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/docker/client.py:85: in from_env
terminalreporter: <_pytest.terminal.TerminalReporter object at 0x109c54ed0>
    timeout=timeout, version=version, **kwargs_from_env(**kwargs)
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/docker/client.py:40: in __init__
    self.api = APIClient(*args, **kwargs)
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/docker/api/client.py:166: in __init__
    base_url, timeout, pool_connections=num_pools
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/docker/transport/sshconn.py:84: in __init__
    self._connect()
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/docker/transport/sshconn.py:94: in _connect
    parsed.hostname, parsed.port, parsed.username,
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/paramiko/client.py:397: in connect
    t.start_client(timeout=timeout)
../../.pyenv/versions/2.7.16/lib/python2.7/site-packages/paramiko/transport.py:597: in start_client
    event.wait(0.1)
../../.pyenv/versions/2.7.16/lib/python2.7/threading.py:614: in wait
    self.__cond.wait(timeout)
../../.pyenv/versions/2.7.16/lib/python2.7/threading.py:359: in wait
    _sleep(delay)
E   KeyboardInterrupt

Apparently one problem is that the ssh connect lacks passing the timeout parameter which makes it blocking, something for which I already opened a PR.

The second issue is why this haappens, which is likely a bug in paramiko as the same code works fine with other versions of Python on the same machine.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with docker/transport/sshconn.py, especially the _connect path shown in the traceback, and reproduce the block with Python 2.7 and DOCKER_HOST=ssh://somehost. Compare the SSH connection behavior across the reported Python and Paramiko versions; done means the reproduction no longer blocks or the compatibility limitation is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.