-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use quarkus with Google Cloud Run And CloudSQL #6634
Conversation
Links to #5824 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comments. Will this work in native too?
@gastaldi To be honest. I compiled it in native mode. run the code. But I didn't actually connect to SQL from Cloud Run. |
@Mihai-B can you make sure it works in native too? |
My concern is that when a SocketFactory class is provided, the extension may need to declare that class as available for reflective access but maybe that's not necessary, hence why I am curious if compiling to native will work OOTB with your changes |
Hi, |
I will deploy it on CloudRun and I will notify how it works
Not actually deployed, I only checked that the properties are set as jdbc properties inside the |
You are right, the jdbc properties are not taken into consideration, can this be Agroal bug or am I doing something wrong? @gastaldi Do you know if the |
@Mihai-B I think it depends on whether there is an extension that enables SSL or not. For example, if an extension requires SSL to be enabled, it should be done like: https://github.com/quarkusio/quarkus/blob/master/extensions/jsch/deployment/src/main/java/io/quarkus/jsch/deployment/JSchProcessor.java#L18-L21 In your case, I guess the solution is to come up with a GCP extension, but I am not sure if that extension should belong to core |
Ok, but if ssl is enabled, it sets the parameter Are we sure that disablessl flag is really set for jdbc connections? Also: My implementation is not google cloud specific, in the end, all I am trying to do is set a connection factory to my jdbc connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require a squash before merging + I added some comments.
extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceRuntimeConfig.java
Outdated
Show resolved
Hide resolved
extensions/agroal/deployment/src/test/java/io/quarkus/agroal/test/GcpDataSourceConfigTest.java
Outdated
Show resolved
Hide resolved
...ions/agroal/deployment/src/test/java/io/quarkus/agroal/test/DefaultDataSourceConfigTest.java
Outdated
Show resolved
Hide resolved
Would love to get some attention to getting this into a release of quarkus, @gastaldi I've verified that it worked to Documentation should add a link that it requires you to activate the https://console.cloud.google.com/apis/api/sqladmin.googleapis.com/overview as well when using cloudsql. Ill see if I can get the native build going and verify that it works for native Dockerfile as well, if not someone else have verified it. This issue is currently a huge show stopper for simply using quarkus as cloud native tool and use Google cloud platform IMO. (minimal application with access to a (cloud)SQL database.) |
@Mihai-B : MySQL error thrown in native mode is the following:
EDIT: Updated log with DEBUG enabled and running locally. (so it is not due to gvisor or something like that)
|
I suspect it is related to oracle/graal#1696 , but I'm not sure how I could try to make a native image with I tried adding it to Unsure what has to be installed inside the |
@gastaldi @Mihai-B : I would love to continue trying to get this to work, as I want to try to get with the linux JNI bindings included for graalvm compiling, and also try to see if it ie helps to disable or prefer IPv4 mode. Do you know someone who might be able to assist me in the right direction for further debugging? |
@norrs I made an account on Zullip, but I am not that active there. I do however see the notifications here unfortunately I don't really understand with what you need assistance with |
@Mihai-B : so I believe oracle/graal#1696 seems to be touching the same troubles I get when trying to make a native binary and run it in cloud run and connect to the cloud sql, and it throws If I understand it correctly, graalvm native binary doesn't link with JNI binding towards Linux amd64 (for syscalls etc), so when we are trying to connect to the Cloud SQL via the library, it fails to create the unix socket. I would love to try to build the native binary with JNI linux amd64 bindings included. So I wonder how may I do this with https://quarkus.io/guides/building-native-image#creating-a-container approach. |
In cloud run you need to add this environment variable: |
@Mihai-B : This was already set, just another value. I tried setting it to 1 just to ensure it wasn't the wrong value, but I still get the same exception thrown. Just for clarification, it servers the webpage etc, it simply cannot connect to the cloud sql instance via unix socket which is required, and it throws the exception. |
@Mihai-B we have multiple users asking for how to connect to Cloud SQL. |
@loicmathieu : it works with JVM without this PR as mentioned at #6634 (comment) (FYI). You are able to specify the additional jdbc properties in the connection URL (quarkus.datasource.url) when using the cloudsql driver. JDBC URL syntax:
Bad things is that you specify the password there as well, and this gets logged to application logs.. (when I played around with it in cloudrun) |
This is wy we need the support for |
I noticed that the connection process to Cloud Run has changed(if I am not mistaken?). I am planning to work on it, I just don't have the time right now. Realistically in 3 weeks I can start working on it but not sooner :( |
@Mihai-B thanks for the heads up. If you don't have a lot of time, you can split your work as I suggested. If you need help, don't hesitate to reach us on Zulip: https://quarkusio.zulipchat.com/#narrow/stream/187038-dev |
@Mihai-B @loicmathieu Any updates regarding this? Seems to me this is required for running any application with a db connection in Google Cloud Run instance, since they have no IP? |
@Mihai-B as you seems to don't have time to handle this, can I took some of your code from this PR to provides the capability to add additional properties to a Quarkus datasource so that we can support Cloud SQL ? |
I think we'd want to have the additionalJdbcProperties feature + a guide explaining how to configure Quarkus to work with Cloud SQL? @loicmathieu if you can work on this, feel free to close this pull-request |
Some environments use these properties for additional metadata (eg. in Google Cloud SQL) Closes quarkusio#6634 Co-authored-by: Mihai B <[email protected]>
I created #12639 for the additional JDBC properties support, but the Google Cloud SQL guide needs to be in a different PR |
Some environments use these properties for additional metadata (eg. in Google Cloud SQL) Closes quarkusio#6634 Co-authored-by: Mihai B <[email protected]>
Some environments use these properties for additional metadata (eg. in Google Cloud SQL) Closes quarkusio#6634 Co-authored-by: Mihai B <[email protected]>
Some environments use these properties for additional metadata (eg. in Google Cloud SQL) Closes quarkusio#6634 Co-authored-by: Mihai B <[email protected]>
Perfect. Apperantly there is a way you can connect to to Google Cloud Sql from CloudRun with a private IP. I am trying this to see how it works. if I can get it working I will submit a tutorial |
Not sure if I am to late, but offcourse, you can do whatever you want with the code. If we can make it work, then I am happy :) |
You could also use public IP with no firewall rule which should work with native build if this still the main issue with socket proxy. |
FYI, I managed to make this work with the latest quarkus release and GraalVM 21.2.0.r16 in the following way:
The produced binary now works fine on Google Cloud Run using postgres Cloud SQL. |
No description provided.