-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[WIP] dns: add support for SRV records in DNS lookup #6379
Conversation
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.
At a high level, this PR and approach looks good, thanks for the contribution. What I'd like to see is some more refactoring in dns_impl.cc
to avoid having code duplication around some of the admittedly sketchy code that is already there, e.g. the exception handling in cares, the self deletion, etc. The work on markForDestruction()
that you've done already is a good example of this :)
/wait
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
WIP |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Still WIP |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
. |
/wait |
/wait |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
This implements a DNS SRV resolver named envoy.srv and handles it's dynamic registration on server startup. Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
Signed-off-by: Venil Noronha <[email protected]>
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.
A few more comments on the current PR. What's the status of this? Is it still WiP?
/wait
}); | ||
dns_timeout->enableTimer(std::chrono::seconds(5)); | ||
|
||
latch.Wait(); |
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 that what you're encountering here is the limitation that exists today in Envoy resolvers; they are synchronous. If you want, I think a separate PR to add asynch resolver plugin support would be welcomed.
* @return if non-null, a handle that can be used to cancel the resolution. | ||
* This is only valid until the invocation of callback or ~DnsResolver(). | ||
*/ | ||
virtual ActiveDnsQuery* resolveSrv(const std::string& dns_name, DnsLookupFamily dns_lookup_family, |
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 know the existing API does it this way, but I'd be interested if we could make ActiveDnsQuery RAII.
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.
Would you be willing to explain what you mean here more? The ActiveDnsQuery abstract class only has one method and no data members. The PendingResolution struct is derived from ActiveDnsQuery and contains data, is that what you want to be RAII? Do you know why a struct was used instead of a class? Was it just to avoid another class definition?
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 I was suggesting that the returned ActiveDnsQuery
be a unique ptr. The idea is that if this returned object is then destructed, it gives you automagic cancellation of the request.
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.
@htuch Are you saying it's better to return a std::unique_ptr<ActiveDnsQuery>
instead of ActiveDnsQuery*
? I'm not quite sure how it actually cancels the pending dns request. Mind elaborating a bit more? (Sorry if the answer is obvious as I'm pretty new to C++ :) )
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.
Right, return std::unique_ptr<ActiveDnsQuery>
. The destructor for ActiveDnsQuery
can then perform the cancellation.
void DnsResolverImpl::PendingSrvResolution::onAresSrvFinishCallback( | ||
std::list<DnsResponse>&& srv_records) { | ||
if (!srv_records.empty()) { | ||
completed_ = true; |
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.
Isn't this true regardless of the length of the srv_records? I.e. the query is over, we're not waiting any longer?
for (auto instance = response.begin(); instance != response.end(); ++instance) { | ||
Address::InstanceConstSharedPtr inst_with_port( | ||
Utility::getAddressWithPort(*instance->address_, current_reply->port)); | ||
mutex->lock(); |
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.
Why are we taking locks? Isn't everything thread local on this dispatcher?
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.
Are threads and dispatchers always coupled? I think so, but I'm not 100% sure. So any operations happening through a particular dispatcher will operate on the same thread?
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.
For the purpose of DNS resolution, this should be true (that they are coupled).
} | ||
}); | ||
} | ||
replies_parsed = true; |
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.
Do we need an explicit replies_parsed
variable here, or can the control logic be made more explicit?
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Is this still actually a WIP or has it really closed out? Seems like there was just a drop off.. |
I've been a little busy so couldn't get it to a finish. I may pick it up later once I have more time. |
Description: This adds support for SRV records in DNS lookup by introducing a new
SrvInstance
type which holds a regularAddress::Instance
objectalong with.priority
andweight
informationRisk Level: Med
Testing: Pending
Docs Changes: Pending
Release Notes: Pending
Fixes #125
Related #517
This PR is currently a WIP. Wiring, configuration, tests, documentation, etc. will be added once the implementation looks okay.
/cc @mattklein123 @htuch