-
Notifications
You must be signed in to change notification settings - Fork 673
DNS lookups should not be case sensitive. #1462
Conversation
dcb1a83
to
ce30e26
Compare
entries := n.entries.tombstone(n.ourName, func(e *Entry) bool { | ||
if hostname != "*" && e.Hostname != hostname { | ||
if hostname != "*" && strings.ToLower(e.Hostname) != lowerHostname { |
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.
fd8b6cb
to
50ba1db
Compare
@inercia would you mind giving this a look please? |
What about the domain? Should that be treated case insensitively too? Also, what's the motivation for dealing with the case insensitivity in the various lookups/comparisons, instead of simply lower-casing the hostname on entry creation? |
Domain is included in the hostname here (see https://github.com/weaveworks/weave/blob/master/weave#L844)
Backwards compatibility. |
Actually this will change the sort order, which means it isn't backwards compatible. Will change to lowercasing on entry creation. |
9da34b1
to
99c7085
Compare
So where does that leave us w.r.t. backward compatibility? |
If you are running a mixed 1.1/1.2 cluster
(1) is probably fine, but (2) looks like a show stopper. We could solve it by:
|
I reckon add/remove should be case-sensitive, but lookup shouldn't be, i.e. it should return all records that match case-insensitively. I suspect this is how normal DNS servers behave, e.g. you can give them a zone file with mixed case records and they will return case-insensitively matching ones on lookup. Worth checking though. |
99c7085
to
85494b1
Compare
Agreed. Attempt (3) - only do case insensitive matching on lookup. Re: backwards compatibility - sort order is preserved. From a 1.1 host, lookup will be case sensitive, and from a 1.2 host, it will not be. |
85494b1
to
5788c34
Compare
Actually this won't work either; sort on a string puts all the upper case before the lowercase: http://play.golang.org/p/UXLptUu953
Back to drawing board. |
The objective is correct. Your implementation is broken. |
If we change the sort order the gossip messages will fail to merge with 1.1 hosts. So we can't change the sort order. We could make lookup O(n), but that sucks. |
How would this manifest itself? |
Routers with different sort orders would drop the connection to each other (nameserver.go:218 would fail) |
Why not sort the received data instead of checking that it is sorted? |
If you're sorting case-sensitively, why would the order be different? |
It wouldn't be but then you cannot do an efficient case _in_sensitive lookup. |
We can do that in 1.2, but the doesn't help with 1.2 sending gossips to 1.1. |
Oh dear. Looks like we are in a bit of pickle here. |
Why can't you decouple the data structure that you gossip (which needs to be case-sensitively sorted for compatibility) from the data structure that you do lookups in? |
@dpw we can, or course. But we haven't done that yet (as it is simpler, with less code, not to). As part of the original design we discussed putting indexes on the entries data structure to accelerate non-hostname lookups (ie reverse lookups, or delete by container id). Perhaps, now that the order of the entires doesn't help for lookup, this is needed for lookups too? |
And a even simpler solution would be to do a case sensitive sort for gossips we send, and a case-insensitive sort on gossips we receive. |
Ok. I interpreted Matthias' "bit of a pickle" comment as suggesting that there was some genuine difficulty, not merely the need to write some code that you'd prefer not to. As you were then. |
af5a36b
to
2e95fba
Compare
@rade PTAL Failures are in 602_proxy_docker_py_test and are unrelated. |
es.checkAndPanic() | ||
defer es.checkAndPanic() | ||
checkAndPanic(CaseInsensitive(*es)) | ||
defer func() { checkAndPanic(CaseInsensitive(*es)) }() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
- On-the-wire gossip messages are sorted case sensitive, but in memory they are sorted case-insensitive. - Add test for case insensitive match on multiple names.
Have tested manually - ubuntu-14 is this branch, ubuntu-15 is 1.1:
|
4ba1f23
to
357174e
Compare
Failure in test is the docker py test_792_explicit_port_protocol failure, unrelated. |
|
||
weave_on $HOST1 launch | ||
|
||
start_container_with_dns $HOST1 --name=test |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
DNS lookups should not be case sensitive. Fixes #1461.
Fixes #1461