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

Fix dns service SRV lookup when service address is a fqdn #6252

Closed
wants to merge 0 commits into from

Conversation

tionebsalocin
Copy link
Contributor

Current implementation returns the node name instead of the service
address.
With this fix when querying for SRV record service address is return in
the SRV record.
And when performing a simple dns lookup it returns a CNAME to the
service address.

Note: Additionnal information has been removed because providing CNAME
does not make sens anymore. A perfect implementation should return A
record with the target IP of the service address.

@hashicorp-cla
Copy link

hashicorp-cla commented Jul 31, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@mkeeler mkeeler left a comment

Choose a reason for hiding this comment

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

@tionebsalocin This looks like a good change overall to me. I definitely think that when the service address is a fqdn/hostname Consul should definitely return it as the SRV target.

I do have one request with regards to the Additional section and ensuring we keep those extra records in the response.

agent/dns.go Outdated
srvRec.Target = addr
} else {
srvRec.Target = fmt.Sprintf("%s.", addr)
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we still need to append any other records besides the CNAME one. In some cases Consul will recursively resolve this CNAME and have the A/AAAA record in the additional section.

So adding something like the following would be good.

   if len(records) > 1 {
      resp.Extra = append(resp.Extra, records[1:]...)
   }

@pierresouchay
Copy link
Contributor

@tionebsalocin good change, don't forget to sign the cla https://cla.hashicorp.com/hashicorp/consul?pullRequest=6252

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