GuzikJakub commented on a change in pull request #4708: [AIRFLOW-3888] HA for 
metastore connection
URL: https://github.com/apache/airflow/pull/4708#discussion_r262053951
 
 

 ##########
 File path: airflow/hooks/hive_hooks.py
 ##########
 @@ -514,20 +520,37 @@ def get_metastore_client(self):
 
             def sasl_factory():
                 sasl_client = sasl.Client()
-                sasl_client.setAttr("host", ms.host)
+                sasl_client.setAttr("host", valid_conn.host)
                 sasl_client.setAttr("service", kerberos_service_name)
                 sasl_client.init()
                 return sasl_client
 
             from thrift_sasl import TSaslClientTransport
-            transport = TSaslClientTransport(sasl_factory, "GSSAPI", socket)
+            transport = TSaslClientTransport(sasl_factory, "GSSAPI", 
conn_socket)
         else:
-            transport = TTransport.TBufferedTransport(socket)
+            transport = TTransport.TBufferedTransport(conn_socket)
 
         protocol = TBinaryProtocol.TBinaryProtocol(transport)
 
         return hmsclient.HMSClient(iprot=protocol)
 
+    def _find_valid_server(self):
+        result = 1
+        conns = self.get_connections(self.conn_id)
+        for conn in conns:
+            host_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            self.log.info("Trying to connect to %s:%s", conn.host, conn.port)
+            try:
+                result = host_socket.connect_ex((conn.host, conn.port))
+                host_socket.close()
 
 Review comment:
   Code corrected and thrown. The wider answer will be prepared below.
   
   I also removed variables such as break, results and valid_conn

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to