diff --git a/plugins/module_utils/_api/errors.py b/plugins/module_utils/_api/errors.py index 90dd5aada..47c284d39 100644 --- a/plugins/module_utils/_api/errors.py +++ b/plugins/module_utils/_api/errors.py @@ -12,6 +12,7 @@ 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 @@ -32,7 +33,7 @@ def create_api_error_from_http_exception(e): try: explanation = response.json()['message'] except ValueError: - explanation = (response.content or '').strip() + explanation = to_native((response.content or '').strip()) cls = APIError if response.status_code == 404: if explanation and ('No such image' in str(explanation) or diff --git a/plugins/module_utils/_api/utils/socket.py b/plugins/module_utils/_api/utils/socket.py index 9193ce30e..792aa0cb5 100644 --- a/plugins/module_utils/_api/utils/socket.py +++ b/plugins/module_utils/_api/utils/socket.py @@ -15,7 +15,6 @@ import select import socket as pysocket import struct -import sys 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) if PY3 and not isinstance(socket, NpipeSocket): - if sys.platform == 'win32': + if not hasattr(select, "poll"): # Limited to 1024 select.select([socket], [], []) else: diff --git a/plugins/module_utils/_api/utils/utils.py b/plugins/module_utils/_api/utils/utils.py index 910b0dc35..db3718d4d 100644 --- a/plugins/module_utils/_api/utils/utils.py +++ b/plugins/module_utils/_api/utils/utils.py @@ -160,6 +160,22 @@ def convert_volume_binds(binds): else: 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( text_type('{0}:{1}:{2}').format(k, bind, mode) ) diff --git a/tests/unit/plugins/module_utils/_api/api/test_client.py b/tests/unit/plugins/module_utils/_api/api/test_client.py index ea0035655..57040b631 100644 --- a/tests/unit/plugins/module_utils/_api/api/test_client.py +++ b/tests/unit/plugins/module_utils/_api/api/test_client.py @@ -619,7 +619,7 @@ def test_read_from_socket_no_stream_tty_demux(self): def test_read_from_socket_no_stream_no_tty(self): 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): res = self.request(stream=False, tty=False, demux=True)