Refactoring Envoy DNS resolution as extension#17479
Refactoring Envoy DNS resolution as extension#17479mattklein123 merged 144 commits intoenvoyproxy:mainfrom
Conversation
… class extension for issue: envoyproxy#14310. Signed-off-by: Yanjun Xiang <[email protected]>
|
This PR is a work in progress. Sending it to start get comments about whether the direction wise look good. There are pending issues need to be done:
|
|
/assign @htuch @yanavlasov @jmarantz @adisuissa This PR is still working in progress as mentioned above. However, I would like to send out this preliminary version out to get comments. Thanks! |
adisuissa
left a comment
There was a problem hiding this comment.
Thanks for working on this!
I've left a few comments/questions.
|
I think this PR also closes #17335. |
|
/assign krajshiva |
|
krajshiva cannot be assigned to this issue. |
htuch
left a comment
There was a problem hiding this comment.
The shape of this solution looks good, thanks! The main thing to sort out is to give each extension a unique proto type
/wait
|
/wait |
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
|
Ping when it's time again to take another look /wait |
thanks! |
|
I think we do? If you hard-code them into the build as we do with TLS it works. I had to do that when I made upstreams pluggable (https://github.com/envoyproxy/envoy/pull/13548/files#) but all the things have changed since then so not convinced a reference PR will be useful. |
|
I guess when we do this: It doesn't work unless it's in the custom build config. I guess that's OK, and we can fix this on the EM side. |
We use the same mechanism to make DNS resolvers required as for TLS, by adding them to the so EM must be not using this mechanism. |
I think this one should work fine, since it will add everything in _required_extensions. |
It's using the same build system, so there must be something else going on? cc @keith |
Ok, let me add this. |
Per @yanavlasov maybe there is something else going on? I guess we need to get to the bottom of it. Either we should add it or we need to figure out a different build issue. |
Signed-off-by: Yanjun Xiang <[email protected]>
okay, sounds good. Earlier stage of this PR, I had been hard-coding c-ares and apple DNS resolver extension into Envoy binary as below. This way, they are always compiled in (based on OS), and not gated by the extension_build_config.bzl (or any other .bzl) file. This should get the EM build pass. Is this the right direction to go? diff --git a/source/common/event/BUILD b/source/common/event/BUILD |
…s-extension Signed-off-by: Yanjun Xiang <[email protected]>
I've just built linux envoy-static using |
|
I just looked through the code, and I think the problem must have to do with the extension registry h/cc files that exist in EM to force registration. I think this is missing for apple. IMO what you have is OK, and EM can add the new registry for the apple stuff, but can we make it fail in a more obvious way? For example, here: Instead of checking for null when you try to do a default setup, can you actually gate this on wdyt? Should be a very small change. cc @goaway |
|
HI, @mattklein123 , If adding a check something like below is purely to flag the extension build file issue, then is it really worthwhile? '#ifdef APPLE' #endif We have other means to easily spot this extension build file issue, e.g., check the bootstrapping logs: [2021-10-14 18:06:35.672][1889399][info][main] [source/server/server.cc:371] statically linked extensions: and: ccing @htuch for his opinion on adding back the "#ifdef APPLE". thanks, |
|
I don't want to actually check the logs, because it's going to fall back to c-ares in a non-obvious way. All I'm saying to do is in the checkApple function do:
|
…er extension is not included Envoy MacOS build file Signed-off-by: Yanjun Xiang <[email protected]>
|
HI, @mattklein123 , Thanks for the comments. I modified checkUseAppleApiForDnsLookups() function to add the #ifdef APPLE, RELEASE_ASSERT() logic you mentioned. PTAL. |
Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
Problem Description:
This PR is the code changes for refactoring Envoy DNS resolution as first class extension for issue: #14310. This is a follow up PR of #17272.
Solution:
1 Move c-ares and Apple DNS resolvers to their own extensions.
2) Create a DnsResolver factory interface, and derive two sub factory classes from it: CaresDnsResolver and AppleDnsResolver, each implement the method to create the corresponding dns_resolver object.
3) Refactor the boostrap_, cluster, dns_cache and dns_filter configuration parsing code, removing the dns_resolution_config parsing logic from them, call a standalone template function to parse the configuration, get a typed configuration. In this, 2.1) if theTypedExtensionConfig is in the config, using it to get the corresponding factory.
2.2) if TypedExtensionConfig is missing, then : if this is MacOS, and the run time flag: envoy.restart_features.use_apple_api_for_dns_lookups is enabled, then have the Envoy config factory synthesize a apple DNS resolver TypedExtensionConfig, and using it to get the apple DNS resolver factory. In all other cases, have the Envoy Synthesize a pseudo-configuration for the c-ares TypedExtensionConfig, and using it to get the cares DNS resolver factory
4) The DNS resolver factory retrieved in 3) will create a corresponding DNS resolver object (cares or apple).
Build:
passed
Testing:
passed
Release Notes:
N/A
Issues: DNS resolver as an extension point #14310
Fix #14310
Signed-off-by: Yanjun Xiang [email protected]
Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]