-
Notifications
You must be signed in to change notification settings - Fork 668
Gossip-based DNS embedded in the router. #1065
Conversation
@rade made a PR as I don't want you comments on changesets to get lost as I push -f. Not ready to merge yet, but it just passed all the tests - https://circleci.com/gh/weaveworks/weave/1438 |
From @rade: many |
-> assigning to you in that case |
39b0eee
to
e660a0b
Compare
btw, I'd prefer if you didn't rebase unless necessary, and especially didn't squash commits - until the very end. Otherwise I'll get bored very quickly following this, since I'd have to re-read the entire diff over and over. |
Fair enough, I'll stop doing it until the end. |
What is the complexity of:
|
Everything other than lookup-by-hostname is O(n), in memory. There is a potential optimisation for receive gossip msg, to make merge ~O(logn). This is on the assumption most gossip message are only a few entries. For large ones O(n) is as good as you can get. |
We should file a follow-on issue to reduce the complexity. |
This PR also doesn't include rate limiting entry addition, which was part of the original design thoughts. Happy to leave that to another PR? |
File an issue for it. |
I think this code does not reuse any of our current WeaveDNS code. What is the plan? Are we going to throw all the code we have now? |
I think there is a race here: I believe it is possible to receive some DNS gossip pertaining to a peer after that peer has been removed from |
@inercia thats right, its a fresh implementation. Some of the code has been borrowed (mainly the dns.go bits) but they've been rewritten. The API should be the same. There is no plan, and what to do with the existing code is up to you and @rade. I guess they could coexist for a while if there is a good reason, but in the end I don't see why we would need both. |
@tomwilkie I don't see the point in throwing all the code we currently have for DNS, specially when most of the code in our current nameserver is transport agnostic. The gossiping mechanism could be plugged in our current zone database, remove the mDNS code (and maybe the cache), and we could reuse the rest of the weaveDNS code... It is well tested code, and many features and solutions for corner cases are already there (for example, the code in this |
@inercia what features are missing from gossipdns/dns.go? |
@tomwilkie Some things...
|
The intention is that they do. Have you spotted a bug?
Whats EDNS?
I intentionally don't want to do that.
dns.go is just a shim onto nameserver.go, which is well tested. Its is also tested by the integration tests. I'm not convinced dns.go and http,go need tests.
All authoritative answers are served from memory by design, so no point in caching. All recursive answers are intentionally uncached - they would be doing a network call anyway, so why cache them? Thanks for taking a look at the code - this is really useful feedback. |
@rade under what situation are you thinking? I'm not familiar enough with the gossip / broadcast / peers code. I could add a list of "live" peers to the nameserver, and filter incoming gossips by that. I would need to add a "peer added" callback to peers.go if one doesn't already exist. Then we'd need to make sure we get the peer-added callback before any gossips from the peer. Thoughts? |
There is no connection between the peer topology gossip and nameserver gossip. Especially not when multiple peers are involved. e.g. Peer A could detect B's death and still receive nameserver gossip from B containing records pertaining to C. So I'd think it can happen quite easily.
That's just the same problem, in reverse. But it's less of an issue as long as it only goes wrong rarely - period gossip will fill in the blanks. Also, instead of a callback you could just ask |
@rade I've added code to filter gossip messages based on the contents of peers. Had to be careful to avoid deadlocks, which meant I had to take the peers lock in a bit of a smelly way. Let me know what you think. Other than EDNS (what is it?) I think this might be close to done. Who do you want to review this? |
// write lock. | ||
if n.peers != nil { | ||
n.peers.RLock() | ||
defer n.peers.RUnlock() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
peers.onGC = append(peers.onGC, callback) | ||
} | ||
|
||
func (peers *Peers) triggerOnGC(removed []*Peer) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
How sure are your that moving the |
@@ -262,13 +290,15 @@ func determineQuorum(initPeerCountFlag int, peers []string) uint { | |||
return quorum | |||
} | |||
|
|||
func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator, defaultSubnet address.CIDR, docker *docker.Client) { | |||
func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator, defaultSubnet address.CIDR, docker *docker.Client, ns *nameserver.Nameserver, dnsserver *nameserver.DNSServer) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Merged coverage report from both integration and unit test: https://circle-artifacts.com/gh/weaveworks/weave/1724/artifacts/0/tmp/circle-artifacts.PPiWyIL/coverage.html
http.go is dragged down as its a short file with unexercised error handling, and has the GET handler for /name/{hostname} which is currently unused and should be removed (will do that now) |
da3bcf0
to
6748c8e
Compare
@inercia how are we getting on with this review? Are we getting close to an LGTM? |
36ec2c7
to
d46301c
Compare
- Nameserver holds a sorted list of (hostname, peer, container id, ip) tuples. - Entries are gossiped using topology gossip / broadcast - only new/updated entries are propogated as expected. - Entries for a given peer are removed when the connection to the peer is lost. - Entries are tombstoned when containers die. Tombstones are kept for 10mins, as they do not need to survive partition, only gossip propagation delay.
Gossip-based DNS embedded in the router.
since $CONTAINER gets stomped on by various functions, in particular populate_dns. Broken by #1065.
propogated as expected.
as they do not need to survive partition, only gossip propagation delay.
Fixes #826, Fixes #987, Fixes #733, Fixes #944, Fixes #833, Fixes #645, Fixes #583, Fixes #338
Left to do:
weave launch-dns
andweave stop-dns
print warning and exit cleanlywhen_weave_running
changeAfter the bulk of the review, we need to:
Not doing in this PR (left to follow-on issues, to be filed)