docker / docker/docker-py

_get_raw_response_socket fails with AttributeError: 'NoneType' object has no attribute 'raw'

Open
#2,247 4 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

docker-py version: 3.7.0
python version: 3.6.6
docker version:

10:04:15 Client:
10:04:15  Version:           18.09.1
10:04:15  API version:       1.39
10:04:15  Go version:        go1.10.6
10:04:15  Git commit:        4c52b90
10:04:15  Built:             Wed Jan  9 19:35:23 2019
10:04:15  OS/Arch:           linux/amd64
10:04:15  Experimental:      false
10:04:15 
10:04:15 Server: Docker Engine - Community
10:04:15  Engine:
10:04:15   Version:          18.09.1
10:04:15   API version:      1.39 (minimum version 1.12)
10:04:15   Go version:       go1.10.6
10:04:15   Git commit:       4c52b90
10:04:15   Built:            Wed Jan  9 19:02:44 2019
10:04:15   OS/Arch:          linux/amd64
10:04:15   Experimental:     false

Code

        # Create database if not exists
        exec_id = self._cli.exec_create(
            container=self.container_name,
            cmd=(
                "bash -c './cockroach sql --insecure"
                " -e \"CREATE DATABASE IF NOT EXISTS {database_name};\"'".format(
                    database_name=database_name,
                )
            ),
        )
        res = self._cli.exec_start(exec_id=exec_id)
        assert self._cli.exec_inspect(exec_id=exec_id)['ExitCode'] == 0, res

Failure

    tests/upgrade/test_cockroach_upgrade.py:51:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    tests/containers/cockroach.py:125: in import_database_from_backup_file
        res = self._cli.exec_start(exec_id=exec_id)
    /venv/lib/python3.6/site-packages/docker/utils/decorators.py:19: in wrapped
        return f(self, resource_id, *args, **kwargs)
    /venv/lib/python3.6/site-packages/docker/api/exec_api.py:168: in exec_start
        return self._read_from_socket(res, stream, tty=tty, demux=demux)
    /venv/lib/python3.6/site-packages/docker/api/client.py:395: in _read_from_socket
        socket = self._get_raw_response_socket(response)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    self = <docker.api.client.APIClient object at 0x7f9e77f84588>, response = <Response [101]>
        def _get_raw_response_socket(self, response):
            self._raise_for_status(response)
            if self.base_url == "http+docker://localnpipe":
                sock = response.raw._fp.fp.raw.sock
            elif self.base_url.startswith('http+docker://ssh'):
                sock = response.raw._fp.fp.channel
            elif six.PY3:
    >           sock = response.raw._fp.fp.raw
    E           AttributeError: 'NoneType' object has no attribute 'raw'
    /venv/lib/python3.6/site-packages/docker/api/client.py:312: AttributeError

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 in docker/api/client.py at _get_raw_response_socket and follow its caller in docker/api/exec_api.py at exec_start. Reproduce the reported exec_start failure with the supplied environment details, then verify that this response path no longer raises AttributeError when reading the raw socket.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.