sassoftware / python-swat

The SAS Scripting Wrapper for Analytics Transfer (SWAT) package is the Python client to SAS Cloud Analytic Services (CAS). It allows users to execute CAS actions and process the results all from Python.
Other
144 stars 61 forks source link

Inconsistent behavior between python installations and libssl #132

Closed sasbxs closed 2 years ago

sasbxs commented 2 years ago

I’m encountering some strange behavior in trying to connect to CAS using python. This is related to a new deployment of Viya 2021.2.4 on Azure with internal site number 70180938.

I added SWAT to a base python installation (the python that comes installed on the operating system) on a CentOS machine. That works great for my test program (as you can see, I can successfully connect to CAS):

[azureuser@agtech-controller ~]$ /usr/bin/python3 Python 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux Type "help", "copyright", "credits" or "license" for more information.

import swat import os os.environ['TKESSL_OPENSSL_LIB'] = '/lib64/libssl.so.1.1' os.environ['CAS_CLIENT_SSL_CA_LIST'] = '/home/azureuser/deployments/ccbu-viya4-2021.2.4/trustedcerts.pem' conn = swat.CAS("sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com", "5570", "sasbxs", "ccbuSAS2021#") conn.serverstatus() >>> import os os.environ['TKESSL_OPENSSL_LIB'] = '/lib64/libssl.so.1.1' os.environ['CAS_CLIENT_SSL_CA_LIST'] = '/home/azureuser/deployments/ccbu-viya4-2021.2.4/trustedcerts.pem' conn = swat.CAS("sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com", "5570", "sasbxs", "ccbuSAS2021#") conn.serverstatus() NOTE: Grid node action status report: 1 nodes, 8 total actions executed. CASResults([('About', {'CAS': 'Cloud Analytic Services', 'Version': '4.00', 'VersionLong': 'V.04.00M0P02142022', 'Viya Release': '20220317.1647527085156', 'Viya Version': 'Stable 2021.2.4', 'Copyright': 'Copyright © 2014-2022 SAS Institute Inc. All Rights Reserved.', 'ServerTime': '2022-04-14T20:47:55Z', 'System': {'Hostname': 'controller.sas-cas-server-default.agtech.svc.cluster.local', 'OS Name': 'Linux', 'OS Family': 'LIN X64', 'OS Release': '5.4.0-1072-azure', 'OS Version': '#75~18.04.1-Ubuntu SMP Wed Mar 2 14:41:08 UTC 2022', 'Model Number': 'x86_64', 'Linux Distribution': 'Red Hat Enterprise Linux release 8.5 (Ootpa)'}, 'license': {'site': 'VIYA 4 FOR AGTECH ENVIRONMENT', 'siteNum': 70180938, 'expires': '17Mar2023:00:00:00', 'gracePeriod': 45, 'warningPeriod': 45}, 'CASHostAccountRequired': 'OPTIONAL', 'Transferred': 'NO'}), ('server', Server Status

nodes actions 0 1 8), ('nodestatus', Node Status

                                            name        role  uptime  running  stalled

0 controller.sas-cas-server-default.agtech.svc.c... controller 0.572 0 0)])

I need to deploy a jupyterhub on the same machine, so I’ve done an anaconda installation of jupyterhub. Ignoring jupyterhub for a moment, if I just start the python that is installed by anaconda and attempt to run EXACTLY the same program I get errors indicating that libssl cannot be found:

[azureuser@agtech-controller bin]$ pwd /opt/anaconda3/bin [azureuser@agtech-controller bin]$ ./python Python 3.8.8 (default, Apr 13 2021, 19:58:26) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.

import swat import os os.environ['TKESSL_OPENSSL_LIB'] = '/lib64/libssl.so.1.1' os.environ['CAS_CLIENT_SSL_CA_LIST'] = '/home/azureuser/deployments/ccbu-viya4-2021.2.4/trustedcerts.pem' conn = swat.CAS("sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com", "5570", "sasbxs", "ccbuSAS2021#") conn.serverstatus() >>> import os os.environ['TKESSL_OPENSSL_LIB'] = '/lib64/libssl.so.1.1' os.environ['CAS_CLIENT_SSL_CA_LIST'] = '/home/azureuser/deployments/ccbu-viya4-2021.2.4/trustedcerts.pem' conn = swat.CAS("sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com", "5570", "sasbxs", "ccbuSAS2021#") ERROR: The TCP/IP negClientSSL support routine failed with status 803fd068. ERROR: Unable to find libssl. An environment variable named TKESSL_OPENSSL_LIB may be used to specify a path. ERROR: TK extension TKEAM could not be loaded. Most likely secure communications are not available on this system. ERROR: Failed to connect to host 'sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com', port 5570. Traceback (most recent call last): File "/opt/anaconda3/lib/python3.8/site-packages/swat/cas/connection.py", line 428, in init self._sw_connection = clib.SW_CASConnection(params) File "/opt/anaconda3/lib/python3.8/site-packages/swat/clib.py", line 133, in SW_CASConnection return _pyswat.SW_CASConnection(args, **kwargs) SystemError: <class 'py38swat.SW_CASConnection'> returned NULL without setting an error

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/opt/anaconda3/lib/python3.8/site-packages/swat/cas/connection.py", line 435, in init raise SWATError(self._sw_error.getLastErrorMessage()) swat.exceptions.SWATError: Could not connect to 'sas-cas-server-default-bin-agtech.eastus2.cloudapp.azure.com' on port 5570.

conn.serverstatus() Traceback (most recent call last): File "", line 1, in NameError: name 'conn' is not defined

I am at a total loss as to how this can happen. They are different versions of python (3.6.8 vs. 3.8.8) so I suppose its possible that different logic is being hit in the SWAT package? I have also attempted this (actually my first attempt) with the most current anaconda that was deploying python 3.9 with the same result – I backed off to an earlier release thinking maybe I’d get a different result. I’m thinking that if I get this resolved then I’ll be able to get jupyterhub working – jobs logically fail there with the same message.

Any suggestions?

Cheers, Brian

sasbxs commented 2 years ago

A reboot of the machine seems to have resolved this issue. Closing.