halkyonio / primaza-poc

Quarkus Primaza Application - POC
1 stars 7 forks source link

Quarkus super heroes - healthCheck cannot connect to DB #180

Closed cmoulliard closed 1 year ago

cmoulliard commented 1 year ago

Issue

Quarkus super heroes - healthCheck cannot connect to the DB. It seems to use the profile accessing "localhost:5432" and not ENV VAR mouted from the secret

2022-12-01 06:33:56,542 WARN  [io.qua.rea.dat.run.ReactiveDatasourceHealthCheck] (vert.x-eventloop-thread-0) Error obtaining database connection for healthcheck of d
atasource '<default>': io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:5432
Caused by: java.net.ConnectException: Connection refused
    at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)

ENV VAR is well mounted within the pod

JAVA_DATA_DIR=/deployments/data
KUBERNETES_NAMESPACE=app
KUBERNETES_SERVICE_PORT_HTTPS=443
REST_HEROES_SERVICE_PORT=80
KUBERNETES_PORT_443_TCP_PORT=443
url=postgresql.db:5432
...

Are we sure that the name of the URL is what the Service Binding Quarkus extension is looking for ? @aureamunoz @iocanel

iocanel commented 1 year ago

I don't see how the quarkus application is going to read url and use it to connect to postgres.

This can be done with the following ways:

The service binding approach can be achived:

For the service binding scenarios: https://developers.redhat.com/articles/2021/12/22/how-use-quarkus-service-binding-operator

cmoulliard commented 1 year ago
  • Semi automatic: Using something like the SBO.

Primaza is doing this job and mount the secret created within a Deployment. See here. Is it correct what we do ? @iocanel

iocanel commented 1 year ago

The approach is not wrong, but it's incomplete. Unless, the secret is strucutred in a way that can be understood by quarkus it won't work. Quarkus can understand properties like: QUARKUS_DATASOURCE_JDBC_URL or if you need something not coupled to Quarkus, a file system strcuture similar to what is used in the service binding spec.

Given, that using environment variables for binding is becoming less and less popular I would focus on the later approach.

cmoulliard commented 1 year ago

on the later approach.

You mean on a file system strcuture similar to what is used in the service binding spec. ? Example ?

Sgitario commented 1 year ago

We're using the Quarkus Super Hero workshop as part of the CI and it works fine. I'm closing this issue as whatever the issue was, it's fixed.