how to externalize a db connection with environmental variables?

Support/help with CloverETL (4.9) and CloverDX (5.0 or newer) implementation problems

ramiro
Posts: 19
Joined: Fri Aug 08, 2014 1:13 am

how to externalize a db connection with environmental variables?

Postby ramiro » Wed Sep 05, 2018 2:11 am

Hello,

We've been using externalized connections for db access, and we were able to apply params in there via config files, so we don't have to hardcode the actual db connection values.

We want to go a step further, and take those params from env variables, instead of from the XML config files, our connection file looks like this:

Code: Select all

#Tue Sep 04 10:45:38 PDT 2018
user=${RDS_DB_USER}
jdbcSpecific=MYSQL
password=${RDS_DB_PASSWORD}
name=RDS_from_env_variables
passwordEncrypted=false
threadSafeConnection=true
database=MYSQL
dbURL=jdbc\:mysql\://${RDS_DB_HOST}\:3306/${RDS_DB_DATABASE}


when we run graphs with it, we get the following error:

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Unknown host: ${RDS_DB_HOST}


according to your documentation, environmental variables can be read the same way other config parameters are:

http://doc.cloveretl.com/documentation/ ... ables.html

and yet, it looks like the connection is failing to translate "${RDS_DB_HOST}" to the actual host we confirmed existed in the env variable...

why would this work for configs coming from the XML param files, but not from env variables?

if dynamic params in the config file won't work, is there a better way to establish the connection off env variables?

cholastal
Posts: 135
Joined: Tue Sep 01, 2015 1:22 pm

Re: how to externalize a db connection with environmental variables?

Postby cholastal » Fri Sep 07, 2018 1:28 pm

Hi Ramiro,

It is possible to use environment variables even in externalized connections. However, under certain circumstances, these variables may not be visible to CloverETL, mainly on Linux where these variables may exist in isolated shells. So, the most reliable way to tell whether the CloverETL can see them is to navigate into the CloverETL Server web console -> Configuration -> System Info -> Environment Variables. It you can see your variable here, you can use it within the software. Here you can find how to reliable define a global environment variable for Linux. If you are on a different OS, please let me know which one it is, whether you can see them in the web console and how did you define the variables. If you do not have a CloverETL Server or if it is located in a different environment, please let me know about it as well.

Best regards,

---
Lukas Cholasta
CloverCARE Support
CloverDX

Visit us online at http://www.cloverdx.com

ramiro
Posts: 19
Joined: Fri Aug 08, 2014 1:13 am

Re: how to externalize a db connection with environmental variables?

Postby ramiro » Fri Sep 07, 2018 10:45 pm

Thanks Lukas,

It is possible indeed! We have the connection working now.

The problem was that we were caching the docker image that run cloverETL.

We run everything in containers, and I was using the old cached version (without the new env variables set) by mistake.

All good, not a cloverETL issue, but thanks for the response!

Ramiro