docker-py
docker-py copied to clipboard
_get_raw_response_socket fails with AttributeError: 'NoneType' object has no attribute 'raw'
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
Hello @mhrabovcin , thank you for filling this issue.
As far as I understand your issue, you have an error one of your test case.
Can you fill the issue with more context? For example looking at the code you pasted, we can't see how the cli
object was initialized.
Thank you!
The initialization of the client: https://github.com/dcos/bouncer/blob/4beab0338e6859508d58f254d52942cd7bdd9fbd/tests/containers/containerbase.py#L33-L55
The code that is interacting with library: https://github.com/dcos/bouncer/blob/4beab0338e6859508d58f254d52942cd7bdd9fbd/tests/containers/cockroach.py
@rumpl or @ulyssessouza PTAL
I have seen a similar problem:
==================================== ERRORS ====================================
_________ ERROR at teardown of my_proprietary_test __________
@pytest.fixture(scope="session", autouse=True)
def docker_logs():
client = docker.from_env()
threads = []
for container in client.containers.list():
name = container.name or container.id
monitor = CmdStdOutThreadedPrinter(container, name)
threads.append(monitor)
monitor.start_process()
yield None
sleep(2)
for thread in threads:
> thread.stop()
test/system_tests/conftest.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/system_tests/threaded_stdout_printer.py:54: in stop
sock = self.client.api._get_raw_response_socket(self.logs._response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <docker.api.client.APIClient object at 0x7f285c597e50>
response = <Response [200]>
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
else:
> sock = response.raw._fp.fp.raw
E AttributeError: 'NoneType' object has no attribute 'raw'
/opt/pysetup/.venv/lib/python3.9/site-packages/docker/api/client.py:324: AttributeError