From 52008df702713444cc5888371e1fc36737d261e2 Mon Sep 17 00:00:00 2001 From: Sylwia Szunejko Date: Wed, 17 Jan 2024 16:59:24 +0100 Subject: [PATCH 1/2] Bump python-driver version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 12746f0..3b3c264 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -scylla-driver==3.26.3 +scylla-driver==3.26.5 geomet==0.2.1.post1 PyYAML==6.0 click==8.1.3 From 2865af0db58f35d600bb574f91ce63fb2e614183 Mon Sep 17 00:00:00 2001 From: Sylwia Szunejko Date: Mon, 15 Jan 2024 19:13:13 +0100 Subject: [PATCH 2/2] Make cqlsh work with unix domain sockets In order to use WhiteListRoundRobinPolicy we have to wrap hostname in UnixSocketEndPoint. This commit adds checking if hostname is a socket, and if so, it adds wrapping hostname into UnixSocketEndPoint. --- bin/cqlsh.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index 627f360..1795b58 100755 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -135,6 +135,7 @@ def find_zip(libprefix): from cassandra.auth import PlainTextAuthProvider from cassandra.cluster import Cluster, EXEC_PROFILE_DEFAULT, ExecutionProfile +from cassandra.connection import UnixSocketEndPoint from cassandra.cqltypes import cql_typename from cassandra.marshal import int64_unpack from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata, TableMetadata, protect_name, protect_names, protect_value) @@ -485,10 +486,14 @@ def __init__(self, hostname, port, color=False, } if cloudconf is None: - kwargs['contact_points'] = (self.hostname,) + if os.path.exists(self.hostname) and stat.S_ISSOCK(os.stat(self.hostname).st_mode): + kwargs['contact_points'] = (UnixSocketEndPoint(self.hostname),) + profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([UnixSocketEndPoint(self.hostname)]) + else: + kwargs['contact_points'] = (self.hostname,) + profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([self.hostname]) kwargs['port'] = self.port kwargs['ssl_context'] = sslhandling.ssl_settings(hostname, CONFIG_FILE) if ssl else None - profiles[EXEC_PROFILE_DEFAULT].load_balancing_policy = WhiteListRoundRobinPolicy([self.hostname]) else: assert 'scylla' in DRIVER_NAME.lower(), f"{DRIVER_NAME} {DRIVER_VERSION} isn't supported by scylla_cloud" kwargs['scylla_cloud'] = cloudconf @@ -2126,7 +2131,10 @@ def do_login(self, parsed): kwargs['contact_points'] = (self.hostname,) kwargs['port'] = self.port kwargs['ssl_context'] = self.conn.ssl_context - kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([self.hostname]) + if os.path.exists(self.hostname) and stat.S_ISSOCK(os.stat(self.hostname).st_mode): + kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([UnixSocketEndPoint(self.hostname)]) + else: + kwargs['load_balancing_policy'] = WhiteListRoundRobinPolicy([self.hostname]) else: kwargs['scylla_cloud'] = self.cloudconf