Skip to content

Comments

Replace unixSocketPath with ipTypes for Cloud SQL TCP#402

Merged
davideme merged 2 commits intomainfrom
claude/peaceful-gagarin
Feb 20, 2026
Merged

Replace unixSocketPath with ipTypes for Cloud SQL TCP#402
davideme merged 2 commits intomainfrom
claude/peaceful-gagarin

Conversation

@davideme
Copy link
Owner

Changes

Update Cloud SQL configuration to use TCP connections instead of Unix sockets:

  • Java: Replace unixSocketPath with ipTypes property set to "PUBLIC,PRIVATE" in DataSourceConfig.java
  • Kotlin: Replace unixSocketPath with ipTypes property set to "PUBLIC,PRIVATE" in DatabaseFactory.kt

This change enables TCP-based connections to Cloud SQL instances while maintaining support for both public and private IP types.

…CP connection

Switch Cloud SQL connector from Unix socket to TCP+TLS by removing
unixSocketPath and setting ipTypes=PUBLIC,PRIVATE, allowing the Java
connector to establish direct connections without a proxy sidecar.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 20, 2026 16:15
…ocketPath

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cloud SQL database configuration to use TCP connections instead of Unix sockets by replacing the unixSocketPath property with ipTypes set to "PUBLIC,PRIVATE". This enables TCP-based connections to Cloud SQL instances while maintaining support for both public and private IP types. The change is applied consistently to both the Java (Spring Boot) and Kotlin (Ktor) implementations of the lamp control API.

Changes:

  • Java implementation: Modified DataSourceConfig.java to use ipTypes instead of unixSocketPath for Cloud SQL connections
  • Kotlin implementation: Modified DatabaseFactory.kt to use ipTypes instead of unixSocketPath for Cloud SQL connections

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/java/src/main/java/org/openapitools/config/DataSourceConfig.java Replaced unixSocketPath data source property with ipTypes property in Cloud SQL configuration
src/kotlin/src/main/kotlin/com/lampcontrol/database/DatabaseFactory.kt Replaced unixSocketPath data source property with ipTypes property in Cloud SQL configuration


config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.postgres.SocketFactory");
config.addDataSourceProperty("unixSocketPath", instanceUnixSocket);
config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE");
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable instanceUnixSocket (line 202) is still being used but is now misleading since the code uses TCP connections with ipTypes instead of Unix sockets. The variable should be renamed to reflect its current purpose of identifying the Cloud SQL instance path. Additionally, this change from unixSocketPath to ipTypes will break existing tests in DataSourceConfigTest.java (lines 97 and 123) that assert the presence of unixSocketPath in data source properties. The tests need to be updated to check for ipTypes with value "PUBLIC,PRIVATE" instead.

Copilot uses AI. Check for mistakes.

hikariConfig.addDataSourceProperty("socketFactory", CLOUD_SQL_SOCKET_FACTORY)
hikariConfig.addDataSourceProperty("unixSocketPath", config.host)
hikariConfig.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE")
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name unixSocketPath in the extractCloudSqlInstance function (line 91) is misleading after this change. Since the code now uses TCP connections with ipTypes instead of Unix sockets, this parameter should be renamed to something more accurate like cloudSqlHostPath or instancePath to reflect that it contains the Cloud SQL instance identifier path. Additionally, this change will break the test in DatabaseFactoryTest.kt (line 70) that asserts the presence of unixSocketPath in data source properties. The test needs to be updated to check for ipTypes with value "PUBLIC,PRIVATE" instead.

Copilot uses AI. Check for mistakes.
config.addDataSourceProperty("socketFactory", "com.google.cloud.sql.postgres.SocketFactory");
config.addDataSourceProperty("unixSocketPath", instanceUnixSocket);
config.addDataSourceProperty("ipTypes", "PUBLIC,PRIVATE");
String cloudSqlInstance = extractCloudSqlInstance(instanceUnixSocket);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After switching from unixSocketPath to ipTypes for TCP connections, the variable name instanceUnixSocket at line 209 is misleading. While the logic correctly extracts the Cloud SQL instance identifier from the path, the variable name suggests Unix socket usage. Consider renaming to instancePath or cloudSqlHostPath to better reflect its purpose of identifying the Cloud SQL instance regardless of connection type.

Copilot uses AI. Check for mistakes.
@davideme davideme merged commit 2dbdbdf into main Feb 20, 2026
8 checks passed
@davideme davideme deleted the claude/peaceful-gagarin branch February 20, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant