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 SRV instancer doesn't deal well with missing port number #892

Closed
bboreham opened this issue Jul 5, 2019 · 10 comments · Fixed by #900
Closed

DNS SRV instancer doesn't deal well with missing port number #892

bboreham opened this issue Jul 5, 2019 · 10 comments · Fixed by #900

Comments

@bboreham
Copy link

bboreham commented Jul 5, 2019

It appears the Kubernetes DNS server will return 0 in the port number slot under some circumstances (most of the ones I tried), and dnssrv/instancer.go turns this into :0 on the address.

Am I holding it wrong, or would you accept a PR to pass back the bare name if the port is 0?

@peterbourgon
Copy link
Member

I find that strange; isn't an SRV record explicitly meant to contain a port? Can e.g. net.Dial possibly succeed without a one?

@bboreham
Copy link
Author

bboreham commented Jul 5, 2019

Looks like if I name the port and look it up by name then I get the number; otherwise zero.

$ nslookup -type=SRV _http._tcp.distributor-h.cortex.svc.cluster.local. 10.244.218.156
Server:		10.244.218.156
Address:	10.244.218.156#53

_http._tcp.distributor-h.cortex.svc.cluster.local	service = 10 50 80 3630646565633364.distributor-h.cortex.svc.cluster.local.
_http._tcp.distributor-h.cortex.svc.cluster.local	service = 10 50 80 6563396264376365.distributor-h.cortex.svc.cluster.local.

$ nslookup -type=SRV distributor-h.cortex.svc.cluster.local. 10.244.218.156
Server:		10.244.218.156
Address:	10.244.218.156#53

distributor-h.cortex.svc.cluster.local	service = 10 50 0 3630646565633364.distributor-h.cortex.svc.cluster.local.
distributor-h.cortex.svc.cluster.local	service = 10 50 0 6563396264376365.distributor-h.cortex.svc.cluster.local.

service definition:

apiVersion: v1
kind: Service
metadata:
  name: distributor-h
  namespace: cortex
spec:
  clusterIP: None
  ports:
    - port: 80
      name: http
  selector:
    name: distributor

@bboreham
Copy link
Author

bboreham commented Jul 5, 2019

And, in the case I want to work, I'm adding a port number before Dial() is called.

@peterbourgon
Copy link
Member

Do you think Kubernetes assumes you'll always try to connect to port 80 by default? Or maybe that it can elide port 80 if it's the only defined port for the service? As a test, could you try to do this with a service that has only one non-80 port defined, and a service with two ports defined?

@peterbourgon
Copy link
Member

To be clear, I'm happy to adjust the behavior for this situation however makes sense. I'm just trying to figure out what makes sense :)

@bboreham
Copy link
Author

bboreham commented Jul 5, 2019

As a test, could you try to do this with a service that has only one non-80 port defined, and a service with two ports defined?

Always zero if I try the bare name,

@peterbourgon
Copy link
Member

So like... does Kubernetes expect you to know the port, and if so how? Or does it do the port routing for you, assuming you connect to 80 by default or something?

@bboreham
Copy link
Author

bboreham commented Jul 8, 2019

I haven't researched those questions, and am unlikely to get to it soon.
Since naming the port does work fine in my case, I amend my request to "go-kit should error if the port returned by DNS is zero", since the failure mode when you Dial :0 is hard to diagnose.

@bboreham
Copy link
Author

bboreham commented Jul 8, 2019

While I'm here, do you know if anyone's done an Instancer via watch on Kubernetes Endpoints?

@peterbourgon
Copy link
Member

Not to my knowledge.

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 a pull request may close this issue.

2 participants