File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 5
5
except ImportError :
6
6
import urllib3
7
7
8
+ from ..errors import DockerException
9
+
8
10
9
11
class CancellableStream (object ):
10
12
"""
@@ -55,9 +57,17 @@ def close(self):
55
57
elif hasattr (sock_raw , '_sock' ):
56
58
sock = sock_raw ._sock
57
59
60
+ elif hasattr (sock_fp , 'channel' ):
61
+ # We're working with a paramiko (SSH) channel, which doesn't
62
+ # support cancelable streams with the current implementation
63
+ raise DockerException (
64
+ 'Cancellable streams not supported for the SSH protocol'
65
+ )
58
66
else :
59
67
sock = sock_fp ._sock
60
- if isinstance (sock , urllib3 .contrib .pyopenssl .WrappedSocket ):
68
+
69
+ if hasattr (urllib3 .contrib , 'pyopenssl' ) and isinstance (
70
+ sock , urllib3 .contrib .pyopenssl .WrappedSocket ):
61
71
sock = sock .socket
62
72
63
73
sock .shutdown (socket .SHUT_RDWR )
Original file line number Diff line number Diff line change @@ -883,6 +883,8 @@ def test_logs_streaming_and_follow(self):
883
883
assert logs == (snippet + '\n ' ).encode (encoding = 'ascii' )
884
884
885
885
@pytest .mark .timeout (5 )
886
+ @pytest .mark .skipif (os .environ .get ('DOCKER_HOST' , '' ).startswith ('ssh://' ),
887
+ reason = 'No cancellable streams over SSH' )
886
888
def test_logs_streaming_and_follow_and_cancel (self ):
887
889
snippet = 'Flowering Nights (Sakuya Iyazoi)'
888
890
container = self .client .create_container (
@@ -1255,7 +1257,8 @@ def test_attach_no_stream(self):
1255
1257
assert output == 'hello\n ' .encode (encoding = 'ascii' )
1256
1258
1257
1259
@pytest .mark .timeout (5 )
1258
- @pytest .mark .xfail (True , reason = 'Cancellable events broken over SSH' )
1260
+ @pytest .mark .skipif (os .environ .get ('DOCKER_HOST' , '' ).startswith ('ssh://' ),
1261
+ reason = 'No cancellable streams over SSH' )
1259
1262
def test_attach_stream_and_cancel (self ):
1260
1263
container = self .client .create_container (
1261
1264
BUSYBOX , 'sh -c "echo hello && sleep 60"' ,
Original file line number Diff line number Diff line change
1
+ import os
1
2
import tempfile
2
3
import threading
3
4
@@ -146,6 +147,8 @@ def test_run_with_streamed_logs(self):
146
147
assert logs [1 ] == b'world\n '
147
148
148
149
@pytest .mark .timeout (5 )
150
+ @pytest .mark .skipif (os .environ .get ('DOCKER_HOST' , '' ).startswith ('ssh://' ),
151
+ reason = 'No cancellable streams over SSH' )
149
152
def test_run_with_streamed_logs_and_cancel (self ):
150
153
client = docker .from_env (version = TEST_API_VERSION )
151
154
out = client .containers .run (
You can’t perform that action at this time.
0 commit comments