-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Make dns resolve paths under _dnslink.example.com #2191
Conversation
ceac63e
to
58dea22
Compare
Great to see this implemented, thanks! |
resChan := make(chan lookupRes) | ||
|
||
for _, prefix := range prefixes { | ||
go workDomain(r, prefix + segments[0], resChan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this leaks goroutines? will want to do a waitgroup sync, and buffer the channel with len(prefixes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, actually no, i think these should not be concurrent and we unfort need them to be sequential for correctness.? and yes, i think we said the _dnslink.
prefix had to be first (is this right @lgierth?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best done concurrently but with _dnslink.
starting first. This way on Unix they will be fully concurrent and in case of everything else sequential.
If someone throws different hashes into both places, sorry, but in my opinion it is his problem. Doing it sequentially creates performance trade-off for someone saying conflicting things (which will be really rare).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, actually no, i think these should not be concurrent and we unfort need them to be sequential for correctness.? and yes, i think we said the _dnslink. prefix had to be first (is this right @lgierth?)
@jbenet yes the _dnslink.
record should take precedence, but we can still resolve both concurrently, and as soon as the prefixed record is resolved, we can make a decision.
That way the runtime is roughly max(A, B)
and not sum(A, B)
.
Made it so goroutines start in order. It is still concurrent in case of Unix and in case of other systems will behave as sequential (they use native lib for resolving). In my opinion if someone places different dnslinks under |
So the final logic
|
I think the goroutines don't neccessarily need to start in order. The only thing that needs to happen is that if (= as soon as)
edit: removed a stray line at the end, s/promises/goroutines/ |
Eventually we might want to put circuit breakers around all DNS lookups, in order to isolate potential DNS breakages that we can do nothing about. But that's a whole different story for another time. |
c3d9180
to
62d06e7
Compare
I've made it so it start concurrently, waits for |
SGTM! @lgierth do "unsuccessful" dns requests get cached? or will this always cause a request hit initially? |
@@ -129,4 +155,6 @@ func TestDNSResolution(t *testing.T) { | |||
testResolution(t, r, "withrecsegment.example.com/test2", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD/sub/segment/subsub/test2", nil) | |||
testResolution(t, r, "withrecsegment.example.com/test3/", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD/sub/segment/subsub/test3/", nil) | |||
testResolution(t, r, "withtrailingrec.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD/sub/segment/", nil) | |||
testResolution(t, r, "double.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil) | |||
testResolution(t, r, "conflict.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjE", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 great testing adds
this LGTM and RFM. want to hear from @lgierth first, as if we're introducing lots of waiting and lack of caching would be good to be 100% sure we want this. |
@jbenet not within go-land. This PR doesn't make the situation worse though. You could argue that resolving two records instead of one makes it more likely that one of them is a "long tail" request, but meh. Let's look into decoupling ourselves from failures outside our reach though! Caches and circuit breakers! :) 👍 RFM |
Can we merge this? We've got two RFM. |
Yep let's get it in, it'll also make my own life a lot easier regarding management of domains :) |
subChan := make(chan lookupRes, 1) | ||
go workDomain(r, "_dnslink." + domain, subChan) | ||
|
||
subRes := <- subChan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to hang this PR up any longer, but if you could change your channel receives to also check the context, that would be super fantastic:
var subRes *lookupRes
select {
case subRes = <-subChan:
case <-ctx.Done():
return "", ctx.Err()
}
do that for this one and the rootChan one a little lower and i'll merge asap
62d06e7
to
4b9c44a
Compare
Thus allowing to CNAME main site entry to gateway and stil specify dnslink. License: MIT Signed-off-by: Jakub Sztandera <kubuxu@gmail.com>
4b9c44a
to
0e18246
Compare
@whyrusleeping I've addressed the comment. |
LGTM |
Make dns resolve paths under _dnslink.example.com
Thus allowing to CNAME main site entry to gateway and still specify dnslink.
Resolves ipfs/notes#39. Option 4 and 5.
Would be great if merged with #2139, and shouldn't even conflict (depending on merger)
Also if you have any comments to the code, I would love to hear them. If anything could have been done better... I am not proficient in Go..