Skip to content
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

chore: Create a new DnsResolver class that wraps the Java DNS API #2045

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Jul 18, 2024

This is a prerequisite for other implementation steps in the Automatic Failover with DNS Configuration story.

Part of #2043.

@hessjcg hessjcg requested a review from a team as a code owner July 18, 2024 21:28
@hessjcg hessjcg force-pushed the gh-2043-java-dns-wrapper branch 2 times, most recently from 300da39 to cb75da8 Compare July 19, 2024 15:24
@hessjcg hessjcg assigned hessjcg and unassigned jackwotherspoon Jul 19, 2024
Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

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

LGTM.

I'd want to try testing the DNS resolver with an integration test to remove the additional indirection between InstanceConnectionNamerResolver -> DNS Resolver -> DNS resolution. If you tested with a real DNS record, you could remove the indrection.

I'll leave this to @jackwotherspoon to sign-off on.

@hessjcg hessjcg force-pushed the gh-2043-java-dns-wrapper branch from 13f3828 to cb75da8 Compare July 24, 2024 20:48
@hessjcg hessjcg force-pushed the gh-2043-java-dns-wrapper branch from cb75da8 to b5c6b97 Compare August 8, 2024 19:06
import javax.naming.NameNotFoundException;

interface DnsResolver {
Collection<String> resolveTxt(String domainName) throws NameNotFoundException;
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are using dnsName in other places, is domainName the same thing or is it a different meaning? If they are one and the same we should consolidate usage to one naming pattern

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Go connector uses DomainName as the configuration field.

I considered fqdn, dnsName, domainName, host, and hostname. FQDN or FullyQualifiedDomainName is too wordy, and dnsName is an expands to "domain name system name", which is self-redundant. I was tempted host, or hostname because that is commonly what it is called as part of the a URL RFC 1738. I decided against it because I wanted to be specific that it needs to contain the domain name.

Go connector uses DNSInstanceConnectionNameResolver for the resolver class name, and DNSResolver for the singleton instance. This refers to the fact that it uses the DNS system to resolve the DomainName into an instance connection name. In retrospect, this felt too wordy, so the class name is DNSResolver in java.

}

/**
* Returns DNS records for a domain name, sorted alphabetically.

Choose a reason for hiding this comment

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

For a domain name, we should only get 1 TXT record if one exists. Why do we have Collection for the return type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We expect exactly 1 DNS record for an instance. However, it is possible that the connector could receive 0, 1, or many DNS records. Other application logic will gracefully handle cases where the number of responses is not 1 as expected. This class is only responsible for resolving DNS and reporting the results. Thus its data model is in line with the DNS protocol, returning a collection that may contain 0 or more responses.

@hessjcg hessjcg requested review from sanmahapatra and enocom August 26, 2024 22:23
Copy link

@sanmahapatra sanmahapatra left a comment

Choose a reason for hiding this comment

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

LGTM

@hessjcg hessjcg force-pushed the gh-2043-java-dns-wrapper branch from b69274f to 35ceacf Compare August 30, 2024 17:54
@hessjcg hessjcg enabled auto-merge (squash) August 30, 2024 17:55
@hessjcg hessjcg merged commit 492a8d1 into main Aug 30, 2024
17 checks passed
@hessjcg hessjcg deleted the gh-2043-java-dns-wrapper branch August 30, 2024 18:01
raresraf pushed a commit to raresraf/cloud-sql-jdbc-socket-factory that referenced this pull request Sep 4, 2024
…API. Part of GoogleCloudPlatform#2043. (GoogleCloudPlatform#2045)

This is a prerequisite for other implementation steps in the Automatic Failover with DNS Configuration story.

Part of GoogleCloudPlatform#2043.
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.

4 participants