mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 20:08:41 +00:00
Update vendored Docker SDK for Python code (#694)
* vendored Docker SDK for Python code: volume: added support for bind propagation https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation Cherry-picked frombea63224e0Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de> Co-authored-by: Milas Bowman <milas.bowman@docker.com> * vendored Docker SDK for Python code: fix: eventlet compatibility Check if poll attribute exists on select module instead of win32 platform check The implementation done in #2865 is breaking usage of docker-py library within eventlet. As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (eventlet/eventlet#608 (comment)), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`. Fixes https://github.com/docker/docker-py/issues/3131 Cherry-picked from78439ebbe1Co-authored-by: Mathieu Virbel <mat@meltingrocks.com> * vendored Docker SDK for Python code: fix: use response.text to get string rather than bytes Adjusted from0618951093Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Co-authored-by: Milas Bowman <milas.bowman@docker.com> * vendored Docker SDK for Python code: Fix missing asserts or assignments Cherry-picked from0566f1260cCo-authored-by: Aarni Koskela <akx@iki.fi> --------- Co-authored-by: Janne Jakob Fleischer <janne.fleischer@ils-forschung.de> Co-authored-by: Milas Bowman <milas.bowman@docker.com> Co-authored-by: Mathieu Virbel <mat@meltingrocks.com> Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com> Co-authored-by: Aarni Koskela <akx@iki.fi>
This commit is contained in:
parent
78801088ae
commit
4d9b85c975
@ -12,6 +12,7 @@ __metaclass__ = type
|
|||||||
|
|
||||||
from ._import_helper import HTTPError as _HTTPError
|
from ._import_helper import HTTPError as _HTTPError
|
||||||
|
|
||||||
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six import raise_from
|
from ansible.module_utils.six import raise_from
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ def create_api_error_from_http_exception(e):
|
|||||||
try:
|
try:
|
||||||
explanation = response.json()['message']
|
explanation = response.json()['message']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
explanation = (response.content or '').strip()
|
explanation = to_native((response.content or '').strip())
|
||||||
cls = APIError
|
cls = APIError
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
if explanation and ('No such image' in str(explanation) or
|
if explanation and ('No such image' in str(explanation) or
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import os
|
|||||||
import select
|
import select
|
||||||
import socket as pysocket
|
import socket as pysocket
|
||||||
import struct
|
import struct
|
||||||
import sys
|
|
||||||
|
|
||||||
from ansible.module_utils.six import PY3, binary_type
|
from ansible.module_utils.six import PY3, binary_type
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ def read(socket, n=4096):
|
|||||||
recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)
|
recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)
|
||||||
|
|
||||||
if PY3 and not isinstance(socket, NpipeSocket):
|
if PY3 and not isinstance(socket, NpipeSocket):
|
||||||
if sys.platform == 'win32':
|
if not hasattr(select, "poll"):
|
||||||
# Limited to 1024
|
# Limited to 1024
|
||||||
select.select([socket], [], [])
|
select.select([socket], [], [])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -160,6 +160,22 @@ def convert_volume_binds(binds):
|
|||||||
else:
|
else:
|
||||||
mode = 'rw'
|
mode = 'rw'
|
||||||
|
|
||||||
|
# NOTE: this is only relevant for Linux hosts
|
||||||
|
# (doesn't apply in Docker Desktop)
|
||||||
|
propagation_modes = [
|
||||||
|
'rshared',
|
||||||
|
'shared',
|
||||||
|
'rslave',
|
||||||
|
'slave',
|
||||||
|
'rprivate',
|
||||||
|
'private',
|
||||||
|
]
|
||||||
|
if 'propagation' in v and v['propagation'] in propagation_modes:
|
||||||
|
if mode:
|
||||||
|
mode = ','.join([mode, v['propagation']])
|
||||||
|
else:
|
||||||
|
mode = v['propagation']
|
||||||
|
|
||||||
result.append(
|
result.append(
|
||||||
text_type('{0}:{1}:{2}').format(k, bind, mode)
|
text_type('{0}:{1}:{2}').format(k, bind, mode)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -619,7 +619,7 @@ class TCPSocketStreamTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_read_from_socket_no_stream_no_tty(self):
|
def test_read_from_socket_no_stream_no_tty(self):
|
||||||
res = self.request(stream=False, tty=False, demux=False)
|
res = self.request(stream=False, tty=False, demux=False)
|
||||||
res == self.stdout_data + self.stderr_data
|
assert res == self.stdout_data + self.stderr_data
|
||||||
|
|
||||||
def test_read_from_socket_no_stream_no_tty_demux(self):
|
def test_read_from_socket_no_stream_no_tty_demux(self):
|
||||||
res = self.request(stream=False, tty=False, demux=True)
|
res = self.request(stream=False, tty=False, demux=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user