-
Notifications
You must be signed in to change notification settings - Fork 5.3k
config: fix dfp config validation #17835
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| #include "source/common/network/transport_socket_options_impl.h" | ||
| #include "source/extensions/common/dynamic_forward_proxy/dns_cache_manager_impl.h" | ||
| #include "source/extensions/filters/network/common/utility.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
|
|
@@ -179,22 +180,29 @@ ClusterFactory::createClusterWithConfig( | |
| context.singletonManager(), context.dispatcher(), context.tls(), context.api(), | ||
| context.runtime(), context.stats(), context.messageValidationVisitor()); | ||
| envoy::config::cluster::v3::Cluster cluster_config = cluster; | ||
| if (cluster_config.has_upstream_http_protocol_options()) { | ||
| if (!proto_config.allow_insecure_cluster_options() && | ||
| (!cluster_config.upstream_http_protocol_options().auto_sni() || | ||
| !cluster_config.upstream_http_protocol_options().auto_san_validation())) { | ||
| throw EnvoyException( | ||
| "dynamic_forward_proxy cluster must have auto_sni and auto_san_validation true when " | ||
| "configured with upstream_http_protocol_options"); | ||
| } | ||
| } else { | ||
| if (!cluster_config.has_upstream_http_protocol_options()) { | ||
| // This sets defaults which will only apply if using old style http config. | ||
| // They will be a no-op if typed_extension_protocol_options are used for | ||
| // http config. | ||
| cluster_config.mutable_upstream_http_protocol_options()->set_auto_sni(true); | ||
| cluster_config.mutable_upstream_http_protocol_options()->set_auto_san_validation(true); | ||
| } | ||
|
|
||
| auto new_cluster = std::make_shared<Cluster>( | ||
| cluster_config, proto_config, context.runtime(), cache_manager_factory, context.localInfo(), | ||
| socket_factory_context, std::move(stats_scope), context.addedViaApi()); | ||
|
|
||
| auto& options = new_cluster->info()->upstreamHttpProtocolOptions(); | ||
|
|
||
| if (!proto_config.allow_insecure_cluster_options()) { | ||
| if (!options.has_value() || | ||
| (!options.value().auto_sni() || !options.value().auto_san_validation())) { | ||
| throw EnvoyException( | ||
| "dynamic_forward_proxy cluster must have auto_sni and auto_san_validation true unless " | ||
| "allow_insecure_cluster_options is set."); | ||
| } | ||
|
Comment on lines
+198
to
+203
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can remove this check from above (and just set the legacy option) since this should check both cases after the cluster is created? |
||
| } | ||
|
|
||
| auto lb = std::make_unique<Cluster::ThreadAwareLoadBalancer>(*new_cluster); | ||
| return std::make_pair(new_cluster, std::move(lb)); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks good! And please move it to be an alphabetical order.