dnsquarkussmallrye

Quarkus and Smallrye Stork cannot find DNS?


I need to send data to a service (service.example.com) which has the following DNS structure (IP addresses and names are pseudonymized):

$ dig service.example.com

; <<>> DiG xxxxxxx <<>> service.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32008
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;service.example.com.       IN  A

;; ANSWER SECTION:
service.example.com.    740 IN  CNAME   service.example.com.some.internal.service.com.
service.example.com.some.internal.service.com. 290 IN A 300.402.251.65
service.example.com.some.internal.service.com. 290 IN A 300.402.250.1
service.example.com.some.internal.service.com. 290 IN A 300.402.249.65
service.example.com.some.internal.service.com. 290 IN A 300.402.248.1

;; Query time: 0 msec
;; SERVER: 10.0.0.102#53(10.0.0.102)
;; WHEN: Mi Apr 10 08:27:42 CEST 2024
;; MSG SIZE  rcvd: 158

I am using Quarkus, but it seems that the rest client of Quarkus cannot handle the different IP addresses, that means that if the first address is not reachable, the rest client cannot find the other ones. That's why Stork was proposed to me. I tried to implement the simplest request, but not even this works. I always get:

2024-04-12 13:51:17.596 ERROR [io.sm.st.im.CachingServiceDiscovery:72] [] [] Failed to fetch service instances: java.lang.RuntimeException: No DNS server was able to resolve 'service.example.com'

This is my setting in Quarkus application.properties (I even assigned a DNS I got from a successful nslookup -debug service.example.com):

quarkus.stork.my-service.service-discovery.type=dns
quarkus.stork.my-service.service-discovery.hostname=service.example.com
quarkus.stork.my-service.service-discovery.port=8443
quarkus.stork.my-service.service-discovery.secure=true
quarkus.stork.my-service.service-discovery.dns-timeout=8s
quarkus.stork.my-service.service-discovery.dns-servers=dns.dns1.de
quarkus.stork.my-service.service-discovery.record-type=A

I initially tried without dns-servers setting, but same problem. I also tried record-type AAAA or SRV, but no change. I also tried https://service.example.com:8443 or service.example.com:8443, but no change.

In Quarkus, I build the client in this way:

RestClientBuilder.newBuilder()
        .baseUri(URI.create("stork://my-service"))
        .build(ServiceHealthInterface.class);

My first though was that the CNAME is the problem, but I also tried with another website, like x.com. The entries look like that:

$ dig x.com

; <<>> DiG xxxxxxx <<>>  x.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28082
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;x.com.             IN  A

;; ANSWER SECTION:
x.com.          292 IN  A   300.144.42.1
x.com.          292 IN  A   300.144.42.129
x.com.          292 IN  A   300.144.42.193
x.com.          292 IN  A   300.144.42.65

;; Query time: 0 msec
;; SERVER: 10.1.1.102#53(10.1.1.102)
;; WHEN: Fr Apr 12 16:02:59 CEST 2024
;; MSG SIZE  rcvd: 98

But I get the same results: Failed to fetch service instances: java.lang.RuntimeException: No DNS server was able to resolve 'x.com'

Do I understand this framework wrong? Is this not designed for my needs?


Solution

  • I found the solution now:

    First of all, I opened all my local ports, so the timeout problem is gone (I still need to narrow it down which ports were exactly the problem).

    Second, I have to create some Header Handler (implement org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory) that extends the header by "Host: service.example.com". This is needed, because otherweise the request runs into a "wrong location" or in other words, it is like invoking the IP in browser (and obviously it doesn necessarily mean that the "real" website is the landing page)