Skip to content
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

API changes for refactoring Envoy DNS resolution as first class extension #17272

Merged
merged 12 commits into from
Jul 15, 2021

Conversation

yanjunxiang-google
Copy link
Contributor

@yanjunxiang-google yanjunxiang-google commented Jul 8, 2021

Problem description:
This is the API changes for refactoring Envoy DNS resolution as first class extension for issue: #14310.

Solution:
This PR added a new DNS resolver type configuration extension in a couple of proto files.
This extension can be used to configure c-ares, apple, or any other DNS resolver types and the related parameters.
When c-ares DNS is configured, :ref:'dns_resolution_config <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.dns_resolution_config>' will be enclosed in this typed_dns_resolver_config. This configuration is to replace the dns_resolution_config configuration eventually.
During the transition period when both dns_resolution_config and typed_dns_resolver_config exists, this configuration is optional. When typed_dns_resolver_config is in place, Envoy will use it and ignore dns_resolution_config. when typed_dns_resolver_config is missing, the default behavior is in place. Envoy will either use c-ares DNS library or apple DNS library based on the compiling flag.

This is the first step towards the fixing of the issue #14310: DNS resolver as an extension point. The follow up work is planned.

Testing:
The code change passed bazel test.

Release Notes:
N/A

Issues: DNS resolver as an extension point #14310

Fix #14310

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:]

…NS resolver

in API definition. This configuration is to support DNS resolution as a first
class Envoy extension. This API change is the first step for that task.

This configuration is to replace above dns_resolution_config.
By default envoy supports c-ares DNS or apple DNS resolvers. This extension can be used
to configure other DNS resolver types.
This configuration is optional. In case it is missing, the default behavior is in place,
which means Envoy will either use c-ares DNS library or apple DNS library based on
the compiling flag. When this configuration is in place, Envoy will use the configured
DNS resolver carried in the extension typed_config field.
In case both typed_dns_resolver_config and dns_resolution_config are configured,
typed_dns_resolver_config take precedence.

Testing:
The code change passed bazel test.

Release Notes:
N/A

Issues: envoyproxy#14310
Fix : N/A

Signed-off-by: Yanjun Xiang <[email protected]>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
envoyproxy/api-shepherds assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #17272 was opened by yanjunxiang-google.

see: more, trace.

@yanjunxiang-google
Copy link
Contributor Author

/assign @htuch @yanavlasov @jmarantz @adisuissa

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense to me.
/wait

api/envoy/config/bootstrap/v3/bootstrap.proto Outdated Show resolved Hide resolved
@yanjunxiang-google
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #17272 (comment) was created by @yanjunxiang-google.

see: more, trace.

@yanjunxiang-google
Copy link
Contributor Author

@envoyproxy/api-shepherds PTAL

// During the transition period when both *dns_resolution_config* and *typed_dns_resolver_config* exists,
// this configuration is optional.
// When *typed_dns_resolver_config* is in place, Envoy will use it and ignore *dns_resolution_config*.
// when *typed_dns_resolver_config* is missing, the default behavior is in place. Envoy will either use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/when/When here and in the other places.
BTW: do you mean the default behavior will be in effect when both typed_dns_resolver_config and dns_resolution_config are missing?

Copy link
Contributor Author

@yanjunxiang-google yanjunxiang-google Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. That's right.

Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htuch I may not be understanding how this is to be configured.

Is the idea that there will be ifdef-controlled selection of apple DNS vs C-Ares, and then on to top of that there would be a configuration-controlled DNS option also?

I had this really naive notion that we could plumb in a dns resolver library in a fashion parallel to the way we plumb in a ThreadFactory, as a pure interface passed into MainCommon. I guess the limitation of that is that there it captures only platform-based differences in resolver type, and would not allow different resolvers to be used per cluster or per-listener, and so the proto-based config allows for that flexibility.

But I don't have as clear a picture as I would like, looking at this proto change, of how this all fits together.

Should we have a doc describing the bigger picture of how this all works?

One thing, for example, I'd like to be able to do is depending on platform, not have C-Ares linked in at all into the codebase. Is that possible with the strategy you are driving?

// or any other DNS resolver types and the related parameters. When c-ares DNS is configured,
// :ref:'dns_resolution_config <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.dns_resolution_config>'
// will be enclosed in this *typed_dns_resolver_config*.
// This configuration is to replace the *dns_resolution_config* configuration eventually.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is to/will/

Express this as a TODO and/or an issue to track it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

// When *typed_dns_resolver_config* is in place, Envoy will use it and ignore *dns_resolution_config*.
// When *typed_dns_resolver_config* is missing, the default behavior is in place. Envoy will either use
// c-ares DNS library or apple DNS library based on the compiling flag.
// [#not-implemented-hide:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also track the addition of a null DNS configuration mode, where no DNS library is compiled in, and DNS resolutions all fail gracefully?

Copy link
Contributor Author

@yanjunxiang-google yanjunxiang-google Jul 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can support the NULL DNS configuration mode if the new typed_dns_resolver_config configuration is in place, and check it and have DNS resolutions fail gracefully.

However, in the case if this configuration is missing, IIUC there is no information for us to identify NULL DNS configuration mode, then, the existing logic (#ifdef) will be executed.

BTW, to make this change backward compatible, this new typed configuration is an optional field for now.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
@yanjunxiang-google
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #17272 (comment) was created by @yanjunxiang-google.

see: more, trace.

@htuch
Copy link
Member

htuch commented Jul 13, 2021

@jmarantz why should DNS be any different than any other extension point? I was envisaging just using static linking/registration, the same way we do with network/HTTP filters, cluster types, transport sockets etc. This is likely flexible enough for everything we need and matches Envoys extensibility model. You can, at build time, decide to use c-ares or Apple DNS resolvers and link or don't link.

We should eliminate all #ifdef as part of this refactor, that would be a litmus test of a successful refactor.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api

htuch
htuch previously approved these changes Jul 13, 2021
Copy link
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/wait

core.v3.DnsResolutionConfig dns_resolution_config = 30;

// DNS resolver type configuration extension. This extension can be used to configure c-ares, apple,
// or any other DNS resolver types and the related parameters. When c-ares DNS is configured,
// :ref:'dns_resolution_config <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.dns_resolution_config>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be <envoy_api_field_core.DnsResultionConfig> instead of <envoy_v3_api_field_config.bootstrap.v3.Bootstrap.dns_resolution_config>

The same issue is in the other proto files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's right. Thanks!

I did some research and found the complete syntax is: :ref:DnsResolutionConfig <envoy_v3_api_msg_config.core.v3.DnsResolutionConfig> and made the change.

Please let me know whether this look good.

Signed-off-by: Yanjun Xiang <[email protected]>
Signed-off-by: Yanjun Xiang <[email protected]>
@mattklein123 mattklein123 merged commit b65b397 into envoyproxy:main Jul 15, 2021
@yanjunxiang-google yanjunxiang-google deleted the dns_refactorying branch July 19, 2021 21:15
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
…sion (envoyproxy#17272)

Adding a core.v3.TypedExtensionConfig typed_dns_resolver_config for DNS resolver
in API definition. This configuration is to support DNS resolution as a first
class Envoy extension. This API change is the first step for that task.

This configuration is to replace above dns_resolution_config.
By default envoy supports c-ares DNS or apple DNS resolvers. This extension can be used
to configure other DNS resolver types.
This configuration is optional. In case it is missing, the default behavior is in place,
which means Envoy will either use c-ares DNS library or apple DNS library based on
the compiling flag. When this configuration is in place, Envoy will use the configured
DNS resolver carried in the extension typed_config field.
In case both typed_dns_resolver_config and dns_resolution_config are configured,
typed_dns_resolver_config take precedence.

Signed-off-by: Yanjun Xiang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DNS resolver as an extension point
7 participants