Skip to content

feat: Use configured DNS name to lookup instance IP address#2244

Merged
hessjcg merged 2 commits intomainfrom
gh-2243-instance-dns-lookup
Jan 13, 2026
Merged

feat: Use configured DNS name to lookup instance IP address#2244
hessjcg merged 2 commits intomainfrom
gh-2243-instance-dns-lookup

Conversation

@hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Dec 17, 2025

When a custom DNS name is used to connect to a Cloud SQL instance, the dialer should first attempt to resolve the custom DNS name to an IP address and use that for the connection. If the lookup fails, the dialer should fall back to using the IP address from the instance metadata.

This change modifies the dialer to:

Use the configured resolver to look up the host's IP address.
Use the IP address from the A record of the custom DNS name if available.
Fall back to the IP address from the instance metadata if the A record is not available.

See also GoogleCloudPlatform/cloud-sql-go-connector#1053

Fixes: #2243

@hessjcg hessjcg requested a review from a team as a code owner December 17, 2025 04:14
@hessjcg hessjcg changed the title Use configured DNS name to lookup instance IP address feat: Use configured DNS name to lookup instance IP address Dec 17, 2025
@hessjcg hessjcg force-pushed the gh-2243-instance-dns-lookup branch 3 times, most recently from d94a69c to afa899f Compare December 17, 2025 05:39
panavenue
panavenue previously approved these changes Dec 17, 2025
Comment on lines +113 to +114
@Override
public List<InetAddress> resolveHost(String hostName) throws UnknownHostException {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add comment description

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@hessjcg hessjcg force-pushed the gh-2243-instance-dns-lookup branch 2 times, most recently from e378737 to 76506fa Compare December 17, 2025 22:45
@hessjcg hessjcg enabled auto-merge (squash) December 17, 2025 22:48
Bug Description
When a custom DNS name is used to connect to a Cloud SQL instance, the dialer should first attempt to resolve the custom DNS name to an IP address and use that for the connection. If the lookup fails, the dialer should fall back to using the IP address from the instance metadata.

This change modifies the dialer to:

Use the configured resolver to look up the host's IP address.
Use the IP address from the A record of the custom DNS name if available.
Fall back to the IP address from the instance metadata if the A record is not available.
See also GoogleCloudPlatform/cloud-sql-go-connector#1053

Fixes: #2243
@hessjcg hessjcg force-pushed the gh-2243-instance-dns-lookup branch from 76506fa to 12b8c64 Compare December 17, 2025 22:49
@hessjcg hessjcg merged commit f89e805 into main Jan 13, 2026
22 checks passed
@hessjcg hessjcg deleted the gh-2243-instance-dns-lookup branch January 13, 2026 01:02
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.

Use configured DNS name to lookup instance IP address

3 participants

Comments