I have written Python App to connect to Impala cluster using Impyla libraries and it was able to extract the data locally. When I deploy the same code in OCP I get the error as:
File "/usr/lib64/python3.9/getpass.py", line 169, in getuser
return pwd.getpwuid(os.getuid())[0]
Keyerror: "getpwuid(): uid not found : 1001100000"
I have not set the above UID anywhere. UID set in my docker file is 1000.
My python script:
from impala.dbapi import connect as iconnect
class ImpalaConnector(object):
def __init__(self):
self.engine = create_engine("impala://", creator=self.conn, echo = True)
def conn(self):
return iconnect(user='my_uid', password='my_pswd', host='my_host', database='my_db', port=20000, auth_mechanism='LDAP', use_ssl=True)
def connect(self):
return self.engine.connect().execution_options(cursor_configuration={'REQUEST_POOL': 'abc'})
impala_connector = ImpalaConnector()
connection = impala_connector.connect()
query = test("select * from tableA limit 5")
result = connection.execute(query)
From the error log, excepetion is thrown from the line - result = connection.execute(query). I tried to set the UID as env variable using below line:
os.environ['UID'] = 'my_uid'
And printed all container env variables in Jenkins file :
stages {
stage('Print Environment Variables') {
steps {
script {
// Use sh step to execute shell command to print environment variables
sh 'env'
}
}
}
But it neither printed UID which I set in my python script or any UID which has value of 1001100000.
Could anyone please provide any input/solutions for this issue ?