Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0.Alpha1 : Unable to connect CloudRun to CloudSql #24743

Closed
anthonydenecheau opened this issue Apr 4, 2022 · 5 comments
Closed

2.0.0.Alpha1 : Unable to connect CloudRun to CloudSql #24743

anthonydenecheau opened this issue Apr 4, 2022 · 5 comments
Labels
kind/question Further information is requested

Comments

@anthonydenecheau
Copy link

anthonydenecheau commented Apr 4, 2022

Describe the bug

I come back to an issue that I opened 2 years ago (#9985) and which was delivered in the 2.0.0.Alpha1 release. I want to connect the CloudRun service to my database instance (CloudSQL)
Unfortunately, the error message has changed but the connection remains impossible.

Expected behavior

No response

Actual behavior

I get this error

Could not obtain connection to query metadata[39m[38;5;203m: org.postgresql.util.PSQLException: The SocketFactory class provided com.google.cloud.sql.postgres.SocketFactory could not be instantiated.

How to Reproduce?

Build image in native mode and deploy on google run (Cloud Build)

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

pom.xml

  <properties>
    <compiler-plugin.version>3.8.1</compiler-plugin.version>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <quarkus-plugin.version>2.0.0.Alpha1</quarkus-plugin.version>
    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
    <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
    <quarkus.platform.version>2.0.0.Alpha1</quarkus.platform.version>
    <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-orm-panache</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-postgresql</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.cloud.sql</groupId>
      <artifactId>postgres-socket-factory</artifactId>
      <version>1.4.4</version>
    </dependency>
  </dependencies>

application.properties

quarkus.datasource.db-kind=other 
quarkus.datasource.jdbc.url=jdbc:postgresql:///${DATABASE_ACTIVE_SCHEMA}?ipTypes=PRIVATE&cloudSqlInstance=<project:zone:instance-name>&socketFactory=com.google.cloud.sql.postgres.SocketFactory&useSSL=false
quarkus.datasource.jdbc.driver=org.postgresql.Driver
quarkus.datasource.username=${DATABASE_USER}
quarkus.datasource.password=${DATABASE_PASSWORD}
quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=<project:zone:instance-name>
quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.postgres.SocketFactory
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect
quarkus.hibernate-orm.log.sql=false
@anthonydenecheau anthonydenecheau added the kind/bug Something isn't working label Apr 4, 2022
@geoand
Copy link
Contributor

geoand commented Apr 5, 2022

cc @loicmathieu

@gsmet gsmet added kind/question Further information is requested and removed kind/bug Something isn't working labels Apr 5, 2022
@gsmet
Copy link
Member

gsmet commented Apr 5, 2022

You are going native with an external library we haven't vetted so you might encounter some issues - not all libraries are working in native out of the box.

The first issue you have is relatively simple to fix: you have to register com.google.cloud.sql.postgres.SocketFactory for reflection. See https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection for guidance about this. The annotation approach with target is the way to go in your case.

Now I have no idea if it will be the only problem you will have. Maybe it would make sense to include an extension here https://github.com/quarkiverse/quarkus-google-cloud-services but that will be for @loicmathieu to decide.

@anthonydenecheau
Copy link
Author

It seems to be working now. I think I misinterpreted the logs. By the way, I also added this solution to my deployment #6634 (comment)
I'm sorry I can't say more...

@loicmathieu
Copy link
Contributor

We document the usage of Cloud SQL but never tested it on native, I need to test it in native. Apparently some people report it to work when adding the google-cloud-graalvm-support library, if it's all that is needed we can add it to the documentation (this library is already used by Quarkus GCP support extension).

We can also add a new extension to the existing GCP extension pack for Cloud SQL for native support as it's a very commonly used cloud service.

@geoand
Copy link
Contributor

geoand commented Oct 19, 2022

Closing as this is about a very old version of Quarkus.

If this is still an issue, feel free to reopen and/or comment

@geoand geoand closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants