refactor(cloudsql): run data-plane SQL via in-container psql, drop JDBC driver#68
Merged
Merged
Conversation
d87ed4f to
87953a2
Compare
…BC driver The Cloud SQL data plane opened JDBC connections from the emulator to the spawned Postgres sidecar to run admin SQL (CREATE DATABASE/ROLE, grants, readiness). That required the org.postgresql JDBC driver, which does not work in the native image (DriverManager: "No suitable driver found", since the java.sql.Driver ServiceLoader isn't registered) and depended on the emulator reaching the sidecar over the network. Run the admin SQL with `psql` via `docker exec` inside the instance container instead (readiness via `pg_isready`; both over TCP to the real server so they wait past the image's socket-only init server). The emulator no longer needs a JDBC driver at all — `org.postgresql` is removed from the project entirely. Adds ContainerLifecycleManager.exec(...). The in-module CloudSqlDataPlaneIntegrationTest (which connected to the real Postgres endpoint as a JDBC client) is removed: it duplicated the compat suite's CloudSqlAdminTest, which already provisions instances for the latest Postgres versions and verifies the endpoint over JDBC — the right home for a real, network-level client test. Verified natively: instances reach RUNNABLE in ~4s and CREATE DATABASE/CREATE ROLE actually create the objects.
87953a2 to
80f8e01
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Cloud SQL data plane opened JDBC connections from the emulator to the spawned Postgres sidecar to run admin SQL (CREATE DATABASE/ROLE, grants, readiness). That required the
org.postgresqlJDBC driver, which does not work in the native image (DriverManager: No suitable driver found) and depended on the emulator reaching the sidecar over the network.Run the admin SQL with
psqlviadocker execinside the instance container instead (readiness viapg_isready; both over TCP so they wait past the image's socket-only init server). The emulator no longer needs a JDBC driver at all —org.postgresqlis removed from the project entirely. AddsContainerLifecycleManager.exec(...)(the docker-java exec classes are already registered for native reflection).The in-module
CloudSqlDataPlaneIntegrationTest(which connected to the real Postgres endpoint as a JDBC client) is removed: it duplicated the compat suite'sCloudSqlAdminTest, which already provisions instances for the latest Postgres versions and verifies the endpoint over JDBC — the right home for a real, network-level client test (and it keeps its own driver dependency).Type of change
fix:)feat:)feat!:orfix!:)GCP Compatibility
No wire-protocol change. Resolves the native-image Cloud SQL provisioning hang (an infinite Postgres-container retry loop, because each
ensureInstancere-ranstartInstanceand every JDBC connect failed). Verified natively: instances reachRUNNABLEin ~4s andCREATE DATABASE/CREATE ROLEactually create the objects in Postgres;compat-terraform/compat-opentofu(which provision a realgoogle_sql_database_instance) now pass, and the compatCloudSqlAdminTestcontinues to verify endpoint usability over JDBC.Checklist
./mvnw testpasses locally (15 Cloud SQL unit tests)compatibility-tests/sdk-test-java(CloudSqlAdminTest)