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
148 stars 62 forks source link

SWAT within containerised (Viya4) environments : Referring to the bin and http K8s services #140

Open SundareshSankaran opened 2 years ago

SundareshSankaran commented 2 years ago

On a Viya 4 environment, I have published the sas-cas-server-default-bin and ..default-http services as NodePorts. A conscious decision has been taken to not deploy them as LoadBalancers in order to reduce entry points and administration overhead.

Accessing a Python editor from within SAS Studio (which is the customer's intended use), I am able to successfully connect to the binary service, through the controller's (internal) IP address - a sequence starting with 10.XX.XX.XX

Services in K8s are commonly accessed through the DNS name of ..svc.cluster.local. In this case, however, I am unable to connect through any of the following patterns (including port of 5570).

Within the connection string of

conn=swat.CAS(hostname=, port=, user=, password=)

hostname = any of the following :

sas-cas-server-default-bin.viya.svc.cluster.local cas-shared-default-bin.viya.svc.cluster.local sas-cas-server-default-controller.viya.svc.cluster.local

What might be the correct naming convention so that I do not have to have my users explicitly state the IP ?

bkemper24 commented 2 years ago

For the namespace 'viya'

sas-cas-server-default-client.viya.svc.cluster.local

SundareshSankaran commented 2 years ago

Thanks, @bkemper24 . I get the following error, though. May I also mention I'm using a self-signed certificate? At the same time, I felt the K8s DNS should take care of the same since this is an internal IP.

>>>
ERROR: The TCP/IP negClientSSL support routine failed with status 807ff019, hostname 10.0.191.XXX port 5570
ERROR: SSL Error: Invalid subject name in partner's certificate. Subject name must match machine name.
ERROR: Failed to connect to host 'sas-cas-server-default-client.viya.svc.cluster.local', port 5570.
Traceback (most recent call last):
  File "/opt/sas/viya/home/sas-pyconfig/default_py/lib/python3.10/site-packages/swat/cas/connection.py", line 437, in __init__
    self._sw_connection = clib.SW_CASConnection(*params)
  File "/opt/sas/viya/home/sas-pyconfig/default_py/lib/python3.10/site-packages/swat/clib.py", line 133, in SW_CASConnection
    return _pyswat.SW_CASConnection(*args, **kwargs)
SystemError: <class 'py310swat.SW_CASConnection'> returned NULL without setting an exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 7, in <module>
  File "/opt/sas/viya/home/sas-pyconfig/default_py/lib/python3.10/site-packages/swat/cas/connection.py", line 444, in __init__
    raise SWATError(self._sw_error.getLastErrorMessage())
swat.exceptions.SWATError: Could not connect to 'sas-cas-server-default-client.viya.svc.cluster.local' on port 5570.
>>>
>>>