From 17c2c06380a361e0f0af6c341efd22ddbf066c7c Mon Sep 17 00:00:00 2001 From: Andor Molnar Date: Mon, 11 May 2026 11:57:52 -0500 Subject: [PATCH 1/3] PHOENIX-7848. Use ZK TLS properties from HBase config if present --- bin/phoenix_utils.py | 17 +++++++++++++++++ bin/sqlline.py | 1 + 2 files changed, 18 insertions(+) diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 27032df5f13..baca08b751a 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -25,6 +25,7 @@ import re import subprocess import sys +import xml.etree.ElementTree as ET def find(pattern, classPaths): paths = classPaths.split(os.pathsep) @@ -126,6 +127,21 @@ def setPath(): # Try to provide something valid hbase_conf_dir = '.' + global zk_tls_args + root = ET.parse(os.path.join(hbase_conf_dir, "hbase-site.xml")).getroot() + zk_hbase_prefix = "hbase.zookeeper.property." + zkcfg = { + prop.find("name").text[len(zk_hbase_prefix):]: prop.find("value").text + for prop in root.findall("property") + if prop.find("name").text.startswith(zk_hbase_prefix) + } + if zkcfg.get('client.secure').lower() == 'true': + zk_tls_args = '-Dzookeeper.client.secure=true ' + \ + '-Dzookeeper.clientCnxnSocket=' + zkcfg['clientCnxnSocket'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.location=' + zkcfg['ssl.trustStore.location'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.type=' + zkcfg['ssl.trustStore.type'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.password=' + zkcfg['ssl.trustStore.password'] + ' ' + global current_dir current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -316,6 +332,7 @@ def common_sqlline_args(parser): setPath() print("phoenix_class_path:", phoenix_class_path) print("hbase_conf_dir:", hbase_conf_dir) + print("zk_tls_args:", zk_tls_args) print("current_dir:", current_dir) print("phoenix_embedded_jar_path:", phoenix_embedded_jar_path) print("phoenix_client_embedded_jar:", phoenix_client_embedded_jar) diff --git a/bin/sqlline.py b/bin/sqlline.py index 09424789de4..c331699e5c3 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -94,6 +94,7 @@ def kill_child(): java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + \ ' ' + opts + \ + ' ' + getattr(phoenix_utils, "zk_tls_args", "") + \ ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + \ phoenix_utils.hadoop_conf + os.pathsep + \ phoenix_utils.sqlline_with_deps_jar + os.pathsep + \ From b2bf44c76b28b7c3d8562454e9fa6aa4639bff7f Mon Sep 17 00:00:00 2001 From: Andor Molnar Date: Tue, 12 May 2026 13:11:09 -0500 Subject: [PATCH 2/3] PHOENIX-7848. Move zk_tls_args to module level --- bin/phoenix_utils.py | 2 ++ bin/sqlline.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index baca08b751a..00509cd440a 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -27,6 +27,8 @@ import sys import xml.etree.ElementTree as ET +zk_tls_args = "" + def find(pattern, classPaths): paths = classPaths.split(os.pathsep) diff --git a/bin/sqlline.py b/bin/sqlline.py index c331699e5c3..7fc8d252c6e 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -94,7 +94,7 @@ def kill_child(): java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + \ ' ' + opts + \ - ' ' + getattr(phoenix_utils, "zk_tls_args", "") + \ + ' ' + phoenix_utils.zk_tls_args + \ ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + \ phoenix_utils.hadoop_conf + os.pathsep + \ phoenix_utils.sqlline_with_deps_jar + os.pathsep + \ From 74268a62412d56616cc508c8562af9ddcf0fd133 Mon Sep 17 00:00:00 2001 From: Andor Molnar Date: Wed, 13 May 2026 16:38:57 -0500 Subject: [PATCH 3/3] PHOENIX-7848. Add exception handler to hbase config file parsing --- bin/phoenix_utils.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 00509cd440a..103bd70c8d7 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -129,20 +129,27 @@ def setPath(): # Try to provide something valid hbase_conf_dir = '.' - global zk_tls_args - root = ET.parse(os.path.join(hbase_conf_dir, "hbase-site.xml")).getroot() - zk_hbase_prefix = "hbase.zookeeper.property." - zkcfg = { - prop.find("name").text[len(zk_hbase_prefix):]: prop.find("value").text - for prop in root.findall("property") - if prop.find("name").text.startswith(zk_hbase_prefix) - } - if zkcfg.get('client.secure').lower() == 'true': - zk_tls_args = '-Dzookeeper.client.secure=true ' + \ - '-Dzookeeper.clientCnxnSocket=' + zkcfg['clientCnxnSocket'] + ' ' + \ - '-Dzookeeper.ssl.trustStore.location=' + zkcfg['ssl.trustStore.location'] + ' ' + \ - '-Dzookeeper.ssl.trustStore.type=' + zkcfg['ssl.trustStore.type'] + ' ' + \ - '-Dzookeeper.ssl.trustStore.password=' + zkcfg['ssl.trustStore.password'] + ' ' + hbase_site_file = os.path.join(hbase_conf_dir, "hbase-site.xml") + try: + global zk_tls_args + root = ET.parse(hbase_site_file).getroot() + zk_hbase_prefix = "hbase.zookeeper.property." + zkcfg = { + prop.find("name").text[len(zk_hbase_prefix):]: prop.find("value").text + for prop in root.findall("property") + if prop.find("name").text.startswith(zk_hbase_prefix) + } + if 'client.secure' in zkcfg and zkcfg.get('client.secure').lower() == 'true': + zk_tls_args = '-Dzookeeper.client.secure=true ' + \ + '-Dzookeeper.clientCnxnSocket=' + zkcfg['clientCnxnSocket'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.location=' + zkcfg['ssl.trustStore.location'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.type=' + zkcfg['ssl.trustStore.type'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.password=' + zkcfg['ssl.trustStore.password'] + ' ' + except Exception as e: + sys.exit( + "ERROR: Failed to parse ZooKeeper TLS properties from '%s': %s" + % (hbase_site_file, repr(e)) + ) global current_dir current_dir = os.path.dirname(os.path.abspath(__file__))