-
Notifications
You must be signed in to change notification settings - Fork 15
Akka.Discovery.Dns #3365
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
base: dev
Are you sure you want to change the base?
Akka.Discovery.Dns #3365
Conversation
8f61cdd
to
9bf29c4
Compare
I managed to get the DNS cluster example working, for both A and SRV records. As mentioned in previous issues SRV required to implement custom resolve handler. |
@anpin VERY nice! is this ready for review or are you still working on it? |
Thanks. Still working on it. Main concerns for now:
|
100% - honestly, I'm not even sure how much Akka.IO's DNS code is even used. I just spent a bunch of time in April / May purging tons of poorly designed older code from the TCP stack in Akka.IO. Wouldn't surprise me if the DNS stack was full of rot too. |
Well it seems that TcpOutgoingConnection is using dotnet dns client these days. However as pointed out in the previous discussion, dotnet dns client is not capable of resolving SRV records, unlike JVM counterpart |
@anpin merged your PR on the main Akka.NET project - are you blocked from working on this until we do a new release of that or are you good to go for now? |
no pressure on my end for a new release. thanks @Aaronontheweb |
Couldn't find a way to unit test TCP fallback for SRV requests, maybe akka/pekko tests have some clues |
Above mentioned PR akkadotnet/akka.net#7727 not present on nuget feed yet, so the tests in CI are still trying to use SimpleDnsManager |
looked at the jvm hocon again and noticed that a few major features were overlooked, e.g. multiple nameservers |
Trying to implement caching now, existing Edit: Actually existing |
only A/AAAA records are supported at this moment
…ependent expirience
seems like some tests in per-existing code are unreliable on linux |
yeah some of the K8s specs are flaky - we'll get to work on reviewing this. thanks for all of your hard work @anpin |
Question, there's a public static object in |
Comparing to the scala code, this is supposed to be handled by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some problems with the current implementation.
src/discovery/dns/Akka.Discovery.Dns/Internal/AsyncDnsClient.cs
Outdated
Show resolved
Hide resolved
src/discovery/dns/Akka.Discovery.Dns/Internal/AsyncDnsClient.cs
Outdated
Show resolved
Hide resolved
Switched query ID from short to int and added lookup to verify ID doesn't exists in the collection. Refactored TcpDropped message and added a handle. I'm on a very unreliable network today, so got to test those TCP failure cases while correcting the code. Made the TCP failures reply back with error on connection error and fail discovery before timeout occurs, for untruncated UDP requests the client will still fail on timeout. @Arkatufus please let me know if I can improve anyhow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed parts so far:
- DNS UDP/TCP packet binary serializer/deserializer, everything looks good.
- General DNS client actor flow, looks good.
Would love to have more people to look over this, but it looks good to me.
Thanks @Arkatufus - I'll take a stab at this in the next day or two |
Gonna ask CoPilot to review it too - why not? |
There was a problem hiding this 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 introduces DNS-based service discovery support to Akka.NET Management, enabling cluster bootstrap through DNS A/AAAA records and SRV records. This new capability allows Akka clusters to discover nodes using DNS infrastructure without requiring specialized service discovery systems.
- Implements a complete DNS discovery provider with async DNS client supporting both standard DNS (A/AAAA) and SRV record resolution
- Adds IPv6 support enhancement to BootstrapCoordinator for proper URI formatting
- Provides comprehensive examples and documentation for various DNS record types
Reviewed Changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated 9 comments.
File | Description |
---|---|
src/management/Akka.Management/Cluster/Bootstrap/Internal/BootstrapCoordinator.cs | Fixes IPv6 address formatting in URI construction |
src/discovery/dns/Akka.Discovery.Dns/*.cs | Complete DNS service discovery implementation including async DNS client, protocol handling, and caching |
src/discovery/dns/Akka.Discovery.Dns.Tests/*.cs | Unit tests for DNS discovery functionality |
src/cluster.bootstrap/examples/discovery/dns/* | Docker-compose examples demonstrating A, AAAA, and SRV record-based discovery |
Comments suppressed due to low confidence (1)
src/discovery/dns/Akka.Discovery.Dns/Internal/AsyncDnsClient.cs
Outdated
Show resolved
Hide resolved
src/discovery/dns/Akka.Discovery.Dns/Internal/AsyncDnsClient.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried running the demo locally and got this:
[+] Running 6/6
✔ node1 Built 0.0s ✔ Network src_akkanet Created 0.1s ✔ Container src-coredns-1 Created 0.2s ✔ Container src-node1-1 Created 0.2s ✔ Container src-node3-1 Created 0.2s ✔ Container src-node2-1 Created 0.3s Attaching to coredns-1, node1-1, node2-1, node3-1
coredns-1 | .:1053
coredns-1 | [INFO] plugin/reload: Running configuration SHA512 = ff9cb9f62c926ec7a3b0d3ee6a542fbe41139b95a7f80cd26dd277e714af89d68c326d83caf0302723cfd0a3ffb7faf4d55ee9220a9e6ac89018003ded3abfef
coredns-1 | CoreDNS-1.10.1
coredns-1 | linux/amd64, go1.20, 055b2c3
node1-1 | ==== AKKA DNS CLUSTER NODE STARTING ====
node1-1 | Hostname: node1.akkacluster
node1-1 | IP addresses: 172.28.0.10
node1-1 | Environment variables:
node1-1 | CLUSTER__PORT: 4053
node1-1 | CLUSTER__IP: 0.0.0.0
node1-1 | MANAGEMENT__PORT: 18558
node1-1 | ACTORSYSTEM: DnsCluster
node1-1 | SERVICENAME: akkacluster.dns.oci
node1-1 | PORTNAME: management
node2-1 | ==== AKKA DNS CLUSTER NODE STARTING ====
node3-1 | ==== AKKA DNS CLUSTER NODE STARTING ====
node1-1 | DNS_PORT: 1053
node2-1 | Hostname: node2.akkacluster
node1-1 exited with code 9
node3-1 | Hostname: node3.akkacluster
node1-1 | DNS_NAMESERVER: 172.28.0.2
node2-1 | IP addresses: 172.28.0.20
node3-1 | IP addresses: 172.28.0.30
node1-1 | ===================================
node2-1 | Environment variables:
node3-1 | Environment variables:
node2-1 exited with code 9
node1-1 | \nPerforming DNS resolution test for 'akkacluster.dns.oci'...
node2-1 | CLUSTER__PORT: 4053
node3-1 | CLUSTER__PORT: 4053
node1-1 | ;; communications error to 127.0.0.11#1053: connection refused
node2-1 | CLUSTER__IP: 0.0.0.0
node3-1 | CLUSTER__IP: 0.0.0.0
node1-1 | ;; communications error to 127.0.0.11#1053: connection refused
node3-1 exited with code 9
node2-1 | MANAGEMENT__PORT: 28558
node3-1 | MANAGEMENT__PORT: 38558
node1-1 | ;; communications error to 127.0.0.11#1053: connection refused
node2-1 | ACTORSYSTEM: DnsCluster
node3-1 | ACTORSYSTEM: DnsCluster
node1-1 |
node2-1 | SERVICENAME: akkacluster.dns.oci
node3-1 | SERVICENAME: akkacluster.dns.oci
node1-1 | ; <<>> DiG 9.18.33-1~deb12u2-Debian <<>> -p 1053 akkacluster.dns.oci
node2-1 | PORTNAME: management
node3-1 | PORTNAME: management
node1-1 | ;; global options: +cmd
node2-1 | DNS_PORT: 1053
node3-1 | DNS_PORT: 1053
node1-1 | ;; no servers could be reached
node2-1 | DNS_NAMESERVER: 172.28.0.2
node3-1 | DNS_NAMESERVER: 172.28.0.2
node2-1 | ===================================
node3-1 | ===================================
node2-1 | \nPerforming DNS resolution test for 'akkacluster.dns.oci'...
node3-1 | \nPerforming DNS resolution test for 'akkacluster.dns.oci'...
node2-1 | ;; communications error to 127.0.0.11#1053: connection refused
node3-1 | ;; communications error to 127.0.0.11#1053: connection refused
node2-1 | ;; communications error to 127.0.0.11#1053: connection refused
node3-1 | ;; communications error to 127.0.0.11#1053: connection refused
node2-1 | ;; communications error to 127.0.0.11#1053: connection refused
node3-1 | ;; communications error to 127.0.0.11#1053: connection refused
node2-1 |
node3-1 |
node2-1 | ; <<>> DiG 9.18.33-1~deb12u2-Debian <<>> -p 1053 akkacluster.dns.oci
node3-1 | ; <<>> DiG 9.18.33-1~deb12u2-Debian <<>> -p 1053 akkacluster.dns.oci
node2-1 | ;; global options: +cmd
node3-1 | ;; global options: +cmd
node2-1 | ;; no servers could be reached
node3-1 | ;; no servers could be reached
It looks like all of the nodes killed themselves after a DNS failure:

I'm running on Windows, but the same thing happened to me when I ran this on a Linux box too. What's supposed to happen when we run the sample?
- **A/AAAA records**: Standard DNS address records that return IP addresses | ||
- **SRV records**: Service records that provide both IP addresses and port information | ||
|
||
## Enabling DNS Discovery Using Akka.Hosting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question from yours, truly: so in order for this to work, do we need a DNS server that is writeable and accessible somewhere inside the network? I'm totally unfamiliar with how to do this outside of using tools like Pulumi to modify DNS records on specific cloud providers - so if I wanted to run this on a bare metal setup, would I need to stand up something like CoreDNS or PiHole?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @anpin
All three examples are running fine on my linux machine, but I will test it in another environment. Attaching logs produced as such: cd ~/projects/Akka.Management/src/cluster.bootstrap/examples/discovery/dns/
./build.ps1 a > a.log
./build.ps1 aaaa > aaaa.log
./build.ps1 srv > srv.log |
I had a rough time running docker on my windows VM and I don't have a physical windows machine I can test it on right now |
Discovery via DNS
Fixes #3364
Changes
IDnsProvider
forasync-dns
resolver to issue direct SRV queries as underlying dotnet implementation resolves only A/AAAAChecklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
Latest
dev
BenchmarksInclude data from the relevant benchmark prior to this change here.
This PR's Benchmarks
Include data from after this change here.