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

DNS query failed in k8s by service name #1694

Closed
dawnbreaks opened this issue Apr 4, 2019 · 9 comments · Fixed by #1697
Closed

DNS query failed in k8s by service name #1694

dawnbreaks opened this issue Apr 4, 2019 · 9 comments · Fixed by #1697
Labels
Milestone

Comments

@dawnbreaks
Copy link

Hi, the DnsAddressEndpointGroup can not resolve successfully by the k8s service name, and must use a fully qualified domain name.
e.g.

//query failed
new DnsAddressEndpointGroupBuilder("service-a").port(8080).build()
//only a fully qualified domain name work
new DnsAddressEndpointGroupBuilder("service-a.infra.svc.cluster.local").port(8080).build()
@dawnbreaks dawnbreaks changed the title DNS query failed in kubernetes by service name DNS query failed in k8s by service name Apr 4, 2019
@trustin
Copy link
Member

trustin commented Apr 4, 2019

Hi! Could you paste your /etc/hosts and /etc/resolv.conf? IIUC, /etc/resolv.conf must contain the following lines:

search infra.svc.cluster.local svc.cluster.local cluster.local 
options ndots:5

@dawnbreaks
Copy link
Author

Yes, the /etc/resolv.conf do contains the search options. It seem that armeria always transform a relative dns name to absulute one by adding a trailing dot at the end of the host name.

nameserver 192.168.80.10
search infra.svc.cluster.local svc.cluster.local cluster.local localdomain
options ndots:5

@dawnbreaks
Copy link
Author

Hi, the DefaultDnsQuestion in netty will transform a relative dns name to an absolute one. So the search options will never work.

@trustin
Copy link
Member

trustin commented Apr 4, 2019

Let us investigate this further. Thanks for reporting. 👍

@trustin trustin added the defect label Apr 4, 2019
@trustin trustin added this to the 0.84.0 milestone Apr 4, 2019
@trustin
Copy link
Member

trustin commented Apr 4, 2019

One more question: Could you set the log level of io.netty.resolver.dns.TraceDnsQueryLifeCycleObserverFactory logger to DEBUG to see what DNS queries Netty sends?

@trustin
Copy link
Member

trustin commented Apr 4, 2019

.. and could you also let us know the version of Armeria and Netty in your class path?

@dawnbreaks
Copy link
Author

armeria version: 0.82.0
netty version: 4.1.33.final

the parent class of DefaultDnsQuestion append the trailing dot to the host name, Please refer to this file AbstractDnsRecord

trustin added a commit to trustin/armeria that referenced this issue Apr 4, 2019
… `/etc/resolv.conf`

Motivation:

When using `Dns*EndpointGroup` with search domains in
`/etc/resolv.conf`, the resolver should try all search domains until the
host name is resolved.

However, it treats the specified host name as a full domain name by
appending a dot (.) to the specified host name.

Modifications:

- Introduce a new `DnsQuestion` implementation called
  `DnsQuestionWithoutTrailingDot` which does not append a dot at the end
  of the host name.

Result:

- `Dns*EndpointGroup` respects the search domains in `/etc/resolv.conf`.
- Fixes line#1694
@trustin
Copy link
Member

trustin commented Apr 4, 2019

Should be fixed with #1697. Please give it a try if you don't mind building Armeria by yourself.

@dawnbreaks
Copy link
Author

Great. I'm on vacation, and will have a try next week. It 'would be appreciated that An new release that fixed this issue will be made soon.

trustin added a commit that referenced this issue Apr 5, 2019
… `/etc/resolv.conf` (#1697)

Motivation:

When using `Dns*EndpointGroup` with search domains in
`/etc/resolv.conf`, the resolver should try all search domains until the
host name is resolved.

However, it treats the specified host name as a full domain name by
appending a dot (.) to the specified host name.

Modifications:

- Introduce a new `DnsQuestion` implementation called
  `DnsQuestionWithoutTrailingDot` which does not append a dot at the end
  of the host name.

Result:

- `Dns*EndpointGroup` respects the search domains in `/etc/resolv.conf`.
- Fixes #1694
fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this issue Sep 19, 2020
… `/etc/resolv.conf` (line#1697)

Motivation:

When using `Dns*EndpointGroup` with search domains in
`/etc/resolv.conf`, the resolver should try all search domains until the
host name is resolved.

However, it treats the specified host name as a full domain name by
appending a dot (.) to the specified host name.

Modifications:

- Introduce a new `DnsQuestion` implementation called
  `DnsQuestionWithoutTrailingDot` which does not append a dot at the end
  of the host name.

Result:

- `Dns*EndpointGroup` respects the search domains in `/etc/resolv.conf`.
- Fixes line#1694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants