feat: Use configured DNS name to lookup instance IP address#1054
feat: Use configured DNS name to lookup instance IP address#1054
Conversation
23384f0 to
6a23ca9
Compare
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.
6a23ca9 to
8561613
Compare
|
I have fixed the test failures in |
8d93506 to
4673f9c
Compare
|
I have resolved the linting issues in |
|
I have verified that the linting checks pass and the tests are green. The PR is now fully updated with the fixes. |
| } else { | ||
| d.logger.Debugf(ctx, | ||
| "[%v] custom DNS name %q resolved to %q, using it to connect", | ||
| cn.String(), cn.DomainName(), addrs[0]) |
There was a problem hiding this comment.
I am guessing it is always in the first item of the array?
There was a problem hiding this comment.
Usually it only returns 1 result. If it returns more than 1 result, that is legal, but probably a mistake.
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:
Fixes #1053