You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/08/15 14:02:32 UTC

[impala] 04/04: IMPALA-8864: Handle py ssl library incompatibility in http mode

This is an automated email from the ASF dual-hosted git repository.

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit fafb2c9786467ebe582b92b27e2990f5789c9c00
Author: Bharath Vissapragada <bh...@cloudera.com>
AuthorDate: Wed Aug 14 22:11:17 2019 -0700

    IMPALA-8864: Handle py ssl library incompatibility in http mode
    
    Older python versions shipped ssl libraries that did not implement
    SSLContext class. THttpClient relies on it. This patch,
    
    - Fails the shell gracefully when such a python version is used.
    - Skips the http test dimension when running the test suite on a
    machine that ships such a python verison (centos 6).
    
    Change-Id: I28846bde0b8bb8f787e6330cddf91645dba4160e
    Reviewed-on: http://gerrit.cloudera.org:8080/14069
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
    Reviewed-by: Tim Armstrong <ta...@cloudera.com>
---
 shell/impala_client.py          | 6 ++++++
 tests/common/test_dimensions.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/shell/impala_client.py b/shell/impala_client.py
index c6915d3..1ba632e 100755
--- a/shell/impala_client.py
+++ b/shell/impala_client.py
@@ -360,6 +360,12 @@ class ImpalaClient(object):
 
   def _get_http_transport(self, connect_timeout_ms):
     """Creates a transport with HTTP as the base."""
+    # Older python versions do not support SSLContext needed by THttpClient. More
+    # context in IMPALA-8864. CentOs 6 ships such an incompatible python version
+    # out of the box.
+    if not hasattr(ssl, "create_default_context"):
+      print_to_stderr("Python version too old. SSLContext not supported.")
+      raise NotImplementedError()
     # Current implementation of THttpClient does a close() and open() of the underlying
     # http connection on every flush() (THRIFT-4600). Due to this, setting a connect
     # timeout does not achieve the desirable result as the subsequent open() could block
diff --git a/tests/common/test_dimensions.py b/tests/common/test_dimensions.py
index 5f26c81..b08fa83 100644
--- a/tests/common/test_dimensions.py
+++ b/tests/common/test_dimensions.py
@@ -122,6 +122,12 @@ def create_beeswax_hs2_dimension():
 # 'hs2-http' dimension is only covered for shell based tests, since they
 # do not rely on Impyla for connections.
 def create_beeswax_hs2_hs2http_dimension():
+  # Older python versions do not support SSLContext object that the thrift
+  # http client implementation depends on. Falls back to a dimension without
+  # http transport. More context in IMPALA-8864.
+  import ssl
+  if not hasattr(ssl, "create_default_context"):
+    return create_beeswax_hs2_dimension()
   return ImpalaTestDimension('protocol', 'beeswax', 'hs2', 'hs2-http')