mirror of https://github.com/docker/docker-py.git
Clear error for cancellable streams over SSH
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
8c86aa90b1
commit
6777c28dee
|
@ -5,6 +5,8 @@ try:
|
|||
except ImportError:
|
||||
import urllib3
|
||||
|
||||
from ..errors import DockerException
|
||||
|
||||
|
||||
class CancellableStream(object):
|
||||
"""
|
||||
|
@ -55,9 +57,17 @@ class CancellableStream(object):
|
|||
elif hasattr(sock_raw, '_sock'):
|
||||
sock = sock_raw._sock
|
||||
|
||||
elif hasattr(sock_fp, 'channel'):
|
||||
# We're working with a paramiko (SSH) channel, which doesn't
|
||||
# support cancelable streams with the current implementation
|
||||
raise DockerException(
|
||||
'Cancellable streams not supported for the SSH protocol'
|
||||
)
|
||||
else:
|
||||
sock = sock_fp._sock
|
||||
if isinstance(sock, urllib3.contrib.pyopenssl.WrappedSocket):
|
||||
|
||||
if hasattr(urllib3.contrib, 'pyopenssl') and isinstance(
|
||||
sock, urllib3.contrib.pyopenssl.WrappedSocket):
|
||||
sock = sock.socket
|
||||
|
||||
sock.shutdown(socket.SHUT_RDWR)
|
||||
|
|
|
@ -883,6 +883,8 @@ Line2'''
|
|||
assert logs == (snippet + '\n').encode(encoding='ascii')
|
||||
|
||||
@pytest.mark.timeout(5)
|
||||
@pytest.mark.skipif(os.environ.get('DOCKER_HOST', '').startswith('ssh://'),
|
||||
reason='No cancellable streams over SSH')
|
||||
def test_logs_streaming_and_follow_and_cancel(self):
|
||||
snippet = 'Flowering Nights (Sakuya Iyazoi)'
|
||||
container = self.client.create_container(
|
||||
|
@ -1255,7 +1257,8 @@ class AttachContainerTest(BaseAPIIntegrationTest):
|
|||
assert output == 'hello\n'.encode(encoding='ascii')
|
||||
|
||||
@pytest.mark.timeout(5)
|
||||
@pytest.mark.xfail(True, reason='Cancellable events broken over SSH')
|
||||
@pytest.mark.skipif(os.environ.get('DOCKER_HOST', '').startswith('ssh://'),
|
||||
reason='No cancellable streams over SSH')
|
||||
def test_attach_stream_and_cancel(self):
|
||||
container = self.client.create_container(
|
||||
BUSYBOX, 'sh -c "echo hello && sleep 60"',
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import tempfile
|
||||
import threading
|
||||
|
||||
|
@ -146,6 +147,8 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
|||
assert logs[1] == b'world\n'
|
||||
|
||||
@pytest.mark.timeout(5)
|
||||
@pytest.mark.skipif(os.environ.get('DOCKER_HOST', '').startswith('ssh://'),
|
||||
reason='No cancellable streams over SSH')
|
||||
def test_run_with_streamed_logs_and_cancel(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
out = client.containers.run(
|
||||
|
|
Loading…
Reference in New Issue