Closed florianrusso closed 1 year ago
On the dependency, I do not believe that Clojure's deps.edn can currently support "POM-only" artifacts which this lib uses post 2.4.0
Maven Dependency: junixsocket-core is now a POM-only artifact (
pom ).
However, if I take the non-optional dep it refers to, that seems to download:
com.kohlschutter.junixsocket/junixsocket-native-common {:mvn/version "2.5.1"}
I'm guessing the other error you saw with the older dep was due to a missing module in the java runtime we compile, I'll look into that. If the dep + module don't add too much weight or other complications, we'll add them.
@florianrusso I've confirmed that junixsocket
doesn't require any modules outside of java.base
, so that is likely OK. I've pushed a docker image with the dep included, yetanalytics/lrsql:junixsocket-test, please try that out and see that works any better.
I'd also suggest checking the JDBC URL you're using, it looks like it has a $
that needs to be escaped, and also double check the subclass you use there "FactoryAr" as I think that might have a typo.
@milt Thanks for your quick reply.
I did some tests locally and still struggle to use unix socket.
the docker compose I used for my test, with the corrected jdbc thanks to you
version: '3'
services:
postgres:
image: postgres:13
ports:
- '5432:5432'
environment:
POSTGRES_USER: test-postgres-db
POSTGRES_DB: test-postgres-db
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- db_socket:/var/run/postgresql
- db_data:/var/lib/postgresql/data
sqllrs:
image: yetanalytics/lrsql:junixsocket-test
command:
- /lrsql/bin/run_postgres.sh
volumes:
- db_socket:/var/run/postgresql
ports:
- '8086:8080'
environment:
LRSQL_API_KEY_DEFAULT: lrsql_api_key
LRSQL_API_SECRET_DEFAULT: lrsql_secret
LRSQL_ADMIN_USER_DEFAULT: lrsql_admin_user
LRSQL_ADMIN_PASS_DEFAULT: lrsql_admin_password
LRSQL_DB_JDBC_URL: "jdbc:postgresql://localhost/test-postgres-db?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24FactoryArg&socketFactoryArg=/var/run/postgresql&sslMode=disable&user=test-postgres-db"
depends_on:
- 'postgres'
volumes:
db_data:
db_socket:
docker-compose up
give me a connection failed attempt. I double checked my JDBC url but seems good to me
To find where is the issue I tried to use a wrong JDBC url ...%24FactoryArg&socketFactoryArg=/var/run/wrong...
. Give me Caused by: java.lang.NoSuchMethodException: org.newsclub.net.unix.AFUNIXSocketFactory.<init>()
instead of connection refused.
Wrong username will gave me the same error.
I also tried with a different volume with no success, the socket is visible locally.
volumes:
- ./postgres/socket:/var/run/postgresql
Hi,
have you tried the docker-compose posted in my previous message ? Is it something I do not use properly ?
@florianrusso sorry, this got lost in the shuffle. I'll try out that compose and see what I can find.
Looks like you need to provide the full path to the socket for it to work like jdbc:postgresql://localhost/test-postgres-db?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432&sslMode=disable&user=test-postgres-db
. When I tried it with that locally it worked.
I'll go ahead and bring the branch up to date and put the PR up for review to add socket support to the main image.
Additionally, it looks like there was a typo in your port for SQL LRS, here is a full working template:
version: '3'
services:
postgres:
image: postgres:13
ports:
- '5432:5432'
environment:
POSTGRES_USER: test-postgres-user
POSTGRES_DB: test-postgres-db
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- db_socket:/var/run/postgresql
- db_data:/var/lib/postgresql/data
sqllrs:
image: yetanalytics/lrsql:junixsocket-test
command:
- /lrsql/bin/run_postgres.sh
volumes:
- db_socket:/var/run/postgresql
ports:
- '8080:8080'
environment:
LRSQL_API_KEY_DEFAULT: lrsql_api_key
LRSQL_API_SECRET_DEFAULT: lrsql_secret
LRSQL_ADMIN_USER_DEFAULT: lrsql_admin_user
LRSQL_ADMIN_PASS_DEFAULT: lrsql_admin_password
LRSQL_DB_JDBC_URL: "jdbc:postgresql://localhost/test-postgres-db?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432&sslMode=disable&user=test-postgres-user"
depends_on:
- 'postgres'
volumes:
db_data:
db_socket:
junixsocket landed in main a while ago, so the instructions above should work fine with the latest
tag. Closing
Hi, we run SQLRS on cloud run, in order to be secure we need java packages to handle unix sockets. What do you think about this? I will be more than happy to open a new pull request but I’m not sure how to do that not being used to clojure. I added the dependencies
I didn’t manage to make tests work. due to unfound jar, so I tried
seems to work during install, but I have an issue to launch the tests locally (with or without any change) and thought it would be a better idea to use docker instead.
to test I updated the docker compose to share the postgresql UNIX socket
docker compose-up give me
references :