From 485580b953822070e2d716319ce8278d83f163f6 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 25 Nov 2019 17:46:07 -0500 Subject: [PATCH 1/4] config: upgrade envoy.ip_tagging to v3alpha. This is a manual pilot of the v3 API type upgade inside of Envoy. The IP tagging filter was picked as its API dependencies are relatively confined in scope, allowing a self-contained PoC to be written. This will be followed by automated upgrade via the API type database for the bulk of Envoy's internals. Part of #8082 Risk level: Low Testing: Additional unit and integration tests added (version_integration_test). Signed-off-by: Harvey Tuch --- source/common/access_log/access_log_impl.cc | 2 +- source/common/config/BUILD | 13 +++ source/common/config/api_type_db.cc | 42 +++++++++ source/common/config/api_type_db.h | 31 +++++++ source/common/config/utility.cc | 34 +++++--- source/common/config/utility.h | 11 ++- source/common/network/BUILD | 1 + source/common/network/cidr_range.cc | 4 + source/common/network/cidr_range.h | 4 + source/common/protobuf/utility.cc | 8 ++ source/common/protobuf/utility.h | 5 ++ source/common/router/config_impl.cc | 12 +-- source/common/upstream/cluster_factory_impl.h | 5 +- .../upstream/transport_socket_match_impl.cc | 3 +- source/common/upstream/upstream_impl.cc | 5 +- .../extensions/filters/http/ip_tagging/BUILD | 3 +- .../filters/http/ip_tagging/config.cc | 4 +- .../filters/http/ip_tagging/config.h | 9 +- .../http/ip_tagging/ip_tagging_filter.cc | 4 +- .../http/ip_tagging/ip_tagging_filter.h | 12 +-- .../filters/network/dubbo_proxy/config.cc | 2 +- .../network/http_connection_manager/config.cc | 2 +- .../filters/network/thrift_proxy/config.cc | 2 +- .../grpc_credentials/aws_iam/config.cc | 4 +- .../file_based_metadata/config.cc | 3 +- .../transport_sockets/tap/config.cc | 6 +- source/server/configuration_impl.cc | 6 +- source/server/listener_impl.cc | 4 +- source/server/listener_manager_impl.cc | 11 +-- source/server/overload_manager_impl.cc | 3 +- .../common/access_log/access_log_impl_test.cc | 4 +- test/common/config/BUILD | 10 +++ test/common/config/api_type_db_test.cc | 74 ++++++++++++++++ test/common/config/utility_test.cc | 8 +- test/common/protobuf/utility_test.cc | 6 ++ .../clusters/aggregate/cluster_test.cc | 3 +- .../dynamic_forward_proxy/cluster_test.cc | 3 +- .../clusters/redis/redis_cluster_test.cc | 9 +- .../http/ip_tagging/ip_tagging_filter_test.cc | 2 +- .../extensions/tracers/datadog/config_test.cc | 3 +- .../tracers/dynamic_ot/config_test.cc | 3 +- .../tracers/lightstep/config_test.cc | 3 +- .../tracers/opencensus/config_test.cc | 6 +- test/extensions/tracers/xray/config_test.cc | 6 +- test/extensions/tracers/zipkin/config_test.cc | 6 +- test/integration/BUILD | 9 ++ test/integration/version_integration_test.cc | 86 +++++++++++++++++++ 47 files changed, 413 insertions(+), 83 deletions(-) create mode 100644 source/common/config/api_type_db.cc create mode 100644 source/common/config/api_type_db.h create mode 100644 test/common/config/api_type_db_test.cc create mode 100644 test/integration/version_integration_test.cc diff --git a/source/common/access_log/access_log_impl.cc b/source/common/access_log/access_log_impl.cc index 7613e3ba9ae0..8db2520a58e5 100644 --- a/source/common/access_log/access_log_impl.cc +++ b/source/common/access_log/access_log_impl.cc @@ -279,7 +279,7 @@ AccessLogFactory::fromProto(const envoy::config::filter::accesslog::v2::AccessLo Config::Utility::getAndCheckFactory( config.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - config, context.messageValidationVisitor(), factory); + config.name(), config, context.messageValidationVisitor(), factory); return factory.createAccessLogInstance(*message, std::move(filter), context); } diff --git a/source/common/config/BUILD b/source/common/config/BUILD index bbce50a5a4d4..cdf44dafcbe4 100644 --- a/source/common/config/BUILD +++ b/source/common/config/BUILD @@ -8,6 +8,17 @@ load( envoy_package() +envoy_cc_library( + name = "api_type_db_lib", + srcs = ["api_type_db.cc"], + hdrs = ["api_type_db.h"], + deps = [ + "//source/common/protobuf", + "//source/common/protobuf:utility_lib", + "@com_github_cncf_udpa//udpa/type/v1:typed_struct_cc", + ], +) + envoy_cc_library( name = "config_provider_lib", srcs = ["config_provider_impl.cc"], @@ -289,7 +300,9 @@ envoy_cc_library( srcs = ["utility.cc"], hdrs = ["utility.h"], deps = [ + ":api_type_db_lib", ":resources_lib", + ":version_converter_lib", "//include/envoy/config:grpc_mux_interface", "//include/envoy/config:subscription_interface", "//include/envoy/local_info:local_info_interface", diff --git a/source/common/config/api_type_db.cc b/source/common/config/api_type_db.cc new file mode 100644 index 000000000000..27f03989b716 --- /dev/null +++ b/source/common/config/api_type_db.cc @@ -0,0 +1,42 @@ +#include "common/config/api_type_db.h" + +#include "common/protobuf/utility.h" + +#include "udpa/type/v1/typed_struct.pb.h" + +namespace Envoy { +namespace Config { + +const Protobuf::Descriptor* +ApiTypeDb::inferEarlierVersionDescriptor(absl::string_view extension_name, + const ProtobufWkt::Any& typed_config, + absl::string_view target_type) { + // This is just a placeholder for where we will load from the API type + // database. + absl::string_view type = TypeUtil::typeUrlToDescriptorFullName(typed_config.type_url()); + + udpa::type::v1::TypedStruct typed_struct; + if (type == udpa::type::v1::TypedStruct::default_instance().GetDescriptor()->full_name()) { + MessageUtil::unpackTo(typed_config, typed_struct); + type = TypeUtil::typeUrlToDescriptorFullName(typed_struct.type_url()); + ENVOY_LOG_MISC(debug, "Extracted embedded type {}", type); + } + + // We have an earlier version if (i) we know about the extension (ii) its type + // is different (v3alpha vs. v2) and (iii) we haven't reached the end of the + // upgrade chain. + if (extension_name == "envoy.ip_tagging" && type != target_type && + target_type != "envoy.config.filter.http.ip_tagging.v2.IPTagging") { + const Protobuf::Descriptor* desc = + Protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName( + "envoy.config.filter.http.ip_tagging.v2.IPTagging"); + ASSERT(desc != nullptr); + ENVOY_LOG_MISC(debug, "Inferred {}", desc->full_name()); + return desc; + } + + return nullptr; +} + +} // namespace Config +} // namespace Envoy diff --git a/source/common/config/api_type_db.h b/source/common/config/api_type_db.h new file mode 100644 index 000000000000..defbec45c086 --- /dev/null +++ b/source/common/config/api_type_db.h @@ -0,0 +1,31 @@ +#pragma once + +#include "common/protobuf/protobuf.h" + +#include "absl/strings/string_view.h" + +namespace Envoy { +namespace Config { + +class ApiTypeDb { +public: + /** + * Based on the presented extension config and name, determine if this is + * configuration for an earlier version than the latest alpha version + * supported by Envoy internally. If so, return the descriptor for the earlier + * message, to support upgrading via VersionConverter::upgrade(). + * + * @param extension_name name of extension corresponding to config. + * @param typed_config opaque config packed in google.protobuf.Any. + * @param target_type target type of conversion. + * @return const Protobuf::Descriptor* descriptor for earlier message version + * corresponding to config, if any, otherwise nulllptr. + */ + static const Protobuf::Descriptor* + inferEarlierVersionDescriptor(absl::string_view extension_name, + const ProtobufWkt::Any& typed_config, + absl::string_view target_type); +}; + +} // namespace Config +} // namespace Envoy diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index d651eda3826b..21ff7e24c322 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -9,7 +9,9 @@ #include "common/common/fmt.h" #include "common/common/hex.h" #include "common/common/utility.h" +#include "common/config/api_type_db.h" #include "common/config/resources.h" +#include "common/config/version_converter.h" #include "common/config/well_known_names.h" #include "common/protobuf/protobuf.h" #include "common/protobuf/utility.h" @@ -240,20 +242,26 @@ envoy::api::v2::ClusterLoadAssignment Utility::translateClusterHosts( return load_assignment; } -namespace { -absl::string_view protoTypeUrlToDescriptorFullName(absl::string_view type_url) { - size_t pos = type_url.find_last_of('/'); - if (pos != absl::string_view::npos) { - type_url = type_url.substr(pos + 1); - } - return type_url; -} -} // namespace - -void Utility::translateOpaqueConfig(const ProtobufWkt::Any& typed_config, +void Utility::translateOpaqueConfig(absl::string_view extension_name, + const ProtobufWkt::Any& typed_config, const ProtobufWkt::Struct& config, ProtobufMessage::ValidationVisitor& validation_visitor, Protobuf::Message& out_proto) { + const Protobuf::Descriptor* earlier_version_desc = ApiTypeDb::inferEarlierVersionDescriptor( + extension_name, typed_config, out_proto.GetDescriptor()->full_name()); + + if (earlier_version_desc != nullptr) { + Protobuf::DynamicMessageFactory dmf; + // Create a previous version message. + auto message = ProtobufTypes::MessagePtr(dmf.GetPrototype(earlier_version_desc)->New()); + ASSERT(message != nullptr); + // Recurse and translateOpaqueConfig for previous version. + translateOpaqueConfig(extension_name, typed_config, config, validation_visitor, *message); + // Update from previous version to current version. + VersionConverter::upgrade(*message, out_proto); + return; + } + static const std::string struct_type = ProtobufWkt::Struct::default_instance().GetDescriptor()->full_name(); static const std::string typed_struct_type = @@ -263,7 +271,7 @@ void Utility::translateOpaqueConfig(const ProtobufWkt::Any& typed_config, // Unpack methods will only use the fully qualified type name after the last '/'. // https://github.com/protocolbuffers/protobuf/blob/3.6.x/src/google/protobuf/any.proto#L87 - absl::string_view type = protoTypeUrlToDescriptorFullName(typed_config.type_url()); + absl::string_view type = TypeUtil::typeUrlToDescriptorFullName(typed_config.type_url()); if (type == typed_struct_type) { udpa::type::v1::TypedStruct typed_struct; @@ -272,7 +280,7 @@ void Utility::translateOpaqueConfig(const ProtobufWkt::Any& typed_config, if (out_proto.GetDescriptor()->full_name() == struct_type) { out_proto.CopyFrom(typed_struct.value()); } else { - type = protoTypeUrlToDescriptorFullName(typed_struct.type_url()); + type = TypeUtil::typeUrlToDescriptorFullName(typed_struct.type_url()); if (type != out_proto.GetDescriptor()->full_name()) { throw EnvoyException("Invalid proto type.\nExpected " + out_proto.GetDescriptor()->full_name() + diff --git a/source/common/config/utility.h b/source/common/config/utility.h index e67db9713892..e6edfbf1add5 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -208,6 +208,7 @@ class Utility { /** * Translate a nested config into a proto message provided by the implementation factory. + * @param extension_name name of extension corresponding to config. * @param enclosing_message proto that contains a field 'config'. Note: the enclosing proto is * provided because for statically registered implementations, a custom config is generally * optional, which means the conversion must be done conditionally. @@ -217,7 +218,7 @@ class Utility { */ template static ProtobufTypes::MessagePtr - translateToFactoryConfig(const ProtoMessage& enclosing_message, + translateToFactoryConfig(absl::string_view extension_name, const ProtoMessage& enclosing_message, ProtobufMessage::ValidationVisitor& validation_visitor, Factory& factory) { ProtobufTypes::MessagePtr config = factory.createEmptyConfigProto(); @@ -225,8 +226,8 @@ class Utility { // Fail in an obvious way if a plugin does not return a proto. RELEASE_ASSERT(config != nullptr, ""); - translateOpaqueConfig(enclosing_message.typed_config(), enclosing_message.config(), - validation_visitor, *config); + translateOpaqueConfig(extension_name, enclosing_message.typed_config(), + enclosing_message.config(), validation_visitor, *config); return config; } @@ -268,12 +269,14 @@ class Utility { /** * Translate opaque config from google.protobuf.Any or google.protobuf.Struct to defined proto * message. + * @param extension_name name of extension corresponding to config. * @param typed_config opaque config packed in google.protobuf.Any * @param config the deprecated google.protobuf.Struct config, empty struct if doesn't exist. * @param validation_visitor message validation visitor instance. * @param out_proto the proto message instantiated by extensions */ - static void translateOpaqueConfig(const ProtobufWkt::Any& typed_config, + static void translateOpaqueConfig(absl::string_view extension_name, + const ProtobufWkt::Any& typed_config, const ProtobufWkt::Struct& config, ProtobufMessage::ValidationVisitor& validation_visitor, Protobuf::Message& out_proto); diff --git a/source/common/network/BUILD b/source/common/network/BUILD index 4b558ffaea7e..6fdc4544c5bd 100644 --- a/source/common/network/BUILD +++ b/source/common/network/BUILD @@ -52,6 +52,7 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/common:utility_lib", "@envoy_api//envoy/api/v2/core:pkg_cc_proto", + "@envoy_api//envoy/api/v3alpha/core:pkg_cc_proto", ], ) diff --git a/source/common/network/cidr_range.cc b/source/common/network/cidr_range.cc index f59686389a88..1901c267824a 100644 --- a/source/common/network/cidr_range.cc +++ b/source/common/network/cidr_range.cc @@ -114,6 +114,10 @@ CidrRange CidrRange::create(const envoy::api::v2::core::CidrRange& cidr) { return create(Utility::parseInternetAddress(cidr.address_prefix()), cidr.prefix_len().value()); } +CidrRange CidrRange::create(const envoy::api::v3alpha::core::CidrRange& cidr) { + return create(Utility::parseInternetAddress(cidr.address_prefix()), cidr.prefix_len().value()); +} + // static CidrRange CidrRange::create(const std::string& range) { const auto parts = StringUtil::splitToken(range, "/"); diff --git a/source/common/network/cidr_range.h b/source/common/network/cidr_range.h index 44e72585973f..af5371db19f9 100644 --- a/source/common/network/cidr_range.h +++ b/source/common/network/cidr_range.h @@ -4,6 +4,7 @@ #include #include "envoy/api/v2/core/address.pb.h" +#include "envoy/api/v3alpha/core/address.pb.h" #include "envoy/json/json_object.h" #include "envoy/network/address.h" @@ -99,6 +100,9 @@ class CidrRange { * TODO(ccaraman): Update CidrRange::create to support only constructing valid ranges. */ static CidrRange create(const envoy::api::v2::core::CidrRange& cidr); + // The ::v2 and ::v3alpha variants will merge once we land API boosting + // automation. TODO(htuch): make sure this happens. + static CidrRange create(const envoy::api::v3alpha::core::CidrRange& cidr); /** * Given an IP address and a length of high order bits to keep, returns an address diff --git a/source/common/protobuf/utility.cc b/source/common/protobuf/utility.cc index c8aef3fbc260..b5bcfd93bd22 100644 --- a/source/common/protobuf/utility.cc +++ b/source/common/protobuf/utility.cc @@ -613,4 +613,12 @@ void TimestampUtil::systemClockToTimestamp(const SystemTime system_clock_time, .count())); } +absl::string_view TypeUtil::typeUrlToDescriptorFullName(absl::string_view type_url) { + size_t pos = type_url.find_last_of('/'); + if (pos != absl::string_view::npos) { + type_url = type_url.substr(pos + 1); + } + return type_url; +} + } // namespace Envoy diff --git a/source/common/protobuf/utility.h b/source/common/protobuf/utility.h index e1c2c8668889..e0af9ae59ac3 100644 --- a/source/common/protobuf/utility.h +++ b/source/common/protobuf/utility.h @@ -116,6 +116,11 @@ class MissingFieldException : public EnvoyException { MissingFieldException(const std::string& field_name, const Protobuf::Message& message); }; +class TypeUtil { +public: + static absl::string_view typeUrlToDescriptorFullName(absl::string_view type_url); +}; + class RepeatedPtrUtil { public: static std::string join(const Protobuf::RepeatedPtrField& source, diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index fb084e31cb57..903fc124c0fd 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -79,8 +79,8 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry for (const auto& host_predicate : retry_policy.retry_host_predicate()) { auto& factory = Envoy::Config::Utility::getAndCheckFactory( host_predicate.name()); - auto config = Envoy::Config::Utility::translateToFactoryConfig(host_predicate, - validation_visitor, factory); + auto config = Envoy::Config::Utility::translateToFactoryConfig( + host_predicate.name(), host_predicate, validation_visitor, factory); retry_host_predicate_configs_.emplace_back(host_predicate.name(), std::move(config)); } @@ -89,8 +89,9 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry auto& factory = Envoy::Config::Utility::getAndCheckFactory( retry_priority.name()); retry_priority_config_ = - std::make_pair(retry_priority.name(), Envoy::Config::Utility::translateToFactoryConfig( - retry_priority, validation_visitor, factory)); + std::make_pair(retry_priority.name(), + Envoy::Config::Utility::translateToFactoryConfig( + retry_priority.name(), retry_priority, validation_visitor, factory)); } auto host_selection_attempts = retry_policy.host_selection_retry_max_attempts(); @@ -1153,7 +1154,8 @@ createRouteSpecificFilterConfig(const std::string& name, const ProtobufWkt::Any& auto& factory = Envoy::Config::Utility::getAndCheckFactory< Server::Configuration::NamedHttpFilterConfigFactory>(name); ProtobufTypes::MessagePtr proto_config = factory.createEmptyRouteConfigProto(); - Envoy::Config::Utility::translateOpaqueConfig(typed_config, config, validator, *proto_config); + Envoy::Config::Utility::translateOpaqueConfig(name, typed_config, config, validator, + *proto_config); return factory.createRouteSpecificFilterConfig(*proto_config, factory_context, validator); } diff --git a/source/common/upstream/cluster_factory_impl.h b/source/common/upstream/cluster_factory_impl.h index 4b3f536dd3c5..41759e66d390 100644 --- a/source/common/upstream/cluster_factory_impl.h +++ b/source/common/upstream/cluster_factory_impl.h @@ -175,8 +175,9 @@ template class ConfigurableClusterFactoryBase : public Clust Stats::ScopePtr&& stats_scope) override { ProtobufTypes::MessagePtr config = createEmptyConfigProto(); Config::Utility::translateOpaqueConfig( - cluster.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), - socket_factory_context.messageValidationVisitor(), *config); + cluster.cluster_type().name(), cluster.cluster_type().typed_config(), + ProtobufWkt::Struct::default_instance(), socket_factory_context.messageValidationVisitor(), + *config); return createClusterWithConfig(cluster, MessageUtil::downcastAndValidate( *config, context.messageValidationVisitor()), diff --git a/source/common/upstream/transport_socket_match_impl.cc b/source/common/upstream/transport_socket_match_impl.cc index 1b99435cb0d0..7a300a45c91b 100644 --- a/source/common/upstream/transport_socket_match_impl.cc +++ b/source/common/upstream/transport_socket_match_impl.cc @@ -18,7 +18,8 @@ TransportSocketMatcherImpl::TransportSocketMatcherImpl( auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::UpstreamTransportSocketConfigFactory>(socket_config.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - socket_config, factory_context.messageValidationVisitor(), config_factory); + socket_config.name(), socket_config, factory_context.messageValidationVisitor(), + config_factory); FactoryMatch factory_match( socket_match.name(), config_factory.createTransportSocketFactory(*message, factory_context), generateStats(socket_match.name() + ".")); diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index 5c650a0eb253..ab1b47ca8df3 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -137,7 +137,7 @@ createProtocolOptionsConfig(const std::string& name, const ProtobufWkt::Any& typ throw EnvoyException(fmt::format("filter {} does not support protocol options", name)); } - Envoy::Config::Utility::translateOpaqueConfig(typed_config, config, validation_visitor, + Envoy::Config::Utility::translateOpaqueConfig(name, typed_config, config, validation_visitor, *proto_config); return factory->createProtocolOptionsConfig(*proto_config, validation_visitor); @@ -791,7 +791,8 @@ Network::TransportSocketFactoryPtr createTransportSocketFactory( auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::UpstreamTransportSocketConfigFactory>(transport_socket.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - transport_socket, factory_context.messageValidationVisitor(), config_factory); + transport_socket.name(), transport_socket, factory_context.messageValidationVisitor(), + config_factory); return config_factory.createTransportSocketFactory(*message, factory_context); } diff --git a/source/extensions/filters/http/ip_tagging/BUILD b/source/extensions/filters/http/ip_tagging/BUILD index aab10c1124bd..4729cdd983d7 100644 --- a/source/extensions/filters/http/ip_tagging/BUILD +++ b/source/extensions/filters/http/ip_tagging/BUILD @@ -24,7 +24,7 @@ envoy_cc_library( "//source/common/http:headers_lib", "//source/common/network:lc_trie_lib", "//source/common/stats:symbol_table_lib", - "@envoy_api//envoy/config/filter/http/ip_tagging/v2:pkg_cc_proto", + "@envoy_api//envoy/config/filter/http/ip_tagging/v3alpha:pkg_cc_proto", ], ) @@ -40,5 +40,6 @@ envoy_cc_extension( "//source/extensions/filters/http/common:factory_base_lib", "//source/extensions/filters/http/ip_tagging:ip_tagging_filter_lib", "@envoy_api//envoy/config/filter/http/ip_tagging/v2:pkg_cc_proto", + "@envoy_api//envoy/config/filter/http/ip_tagging/v3alpha:pkg_cc_proto", ], ) diff --git a/source/extensions/filters/http/ip_tagging/config.cc b/source/extensions/filters/http/ip_tagging/config.cc index b8f4b51f2025..97830b2a5f64 100644 --- a/source/extensions/filters/http/ip_tagging/config.cc +++ b/source/extensions/filters/http/ip_tagging/config.cc @@ -1,6 +1,6 @@ #include "extensions/filters/http/ip_tagging/config.h" -#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.validate.h" +#include "envoy/config/filter/http/ip_tagging/v3alpha/ip_tagging.pb.validate.h" #include "envoy/registry/registry.h" #include "common/protobuf/utility.h" @@ -13,7 +13,7 @@ namespace HttpFilters { namespace IpTagging { Http::FilterFactoryCb IpTaggingFilterFactory::createFilterFactoryFromProtoTyped( - const envoy::config::filter::http::ip_tagging::v2::IPTagging& proto_config, + const envoy::config::filter::http::ip_tagging::v3alpha::IPTagging& proto_config, const std::string& stat_prefix, Server::Configuration::FactoryContext& context) { IpTaggingFilterConfigSharedPtr config( diff --git a/source/extensions/filters/http/ip_tagging/config.h b/source/extensions/filters/http/ip_tagging/config.h index 361d4acfe6a7..33585288dea2 100644 --- a/source/extensions/filters/http/ip_tagging/config.h +++ b/source/extensions/filters/http/ip_tagging/config.h @@ -1,7 +1,8 @@ #pragma once -#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.h" -#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.validate.h" +#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.h" // For proto descriptors only +#include "envoy/config/filter/http/ip_tagging/v3alpha/ip_tagging.pb.h" +#include "envoy/config/filter/http/ip_tagging/v3alpha/ip_tagging.pb.validate.h" #include "extensions/filters/http/common/factory_base.h" #include "extensions/filters/http/well_known_names.h" @@ -15,13 +16,13 @@ namespace IpTagging { * Config registration for the router filter. @see NamedHttpFilterConfigFactory. */ class IpTaggingFilterFactory - : public Common::FactoryBase { + : public Common::FactoryBase { public: IpTaggingFilterFactory() : FactoryBase(HttpFilterNames::get().IpTagging) {} private: Http::FilterFactoryCb createFilterFactoryFromProtoTyped( - const envoy::config::filter::http::ip_tagging::v2::IPTagging& proto_config, + const envoy::config::filter::http::ip_tagging::v3alpha::IPTagging& proto_config, const std::string& stats_prefix, Server::Configuration::FactoryContext& context) override; }; diff --git a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.cc b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.cc index fe3648c082de..6f92aac73a01 100644 --- a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.cc +++ b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.cc @@ -11,7 +11,7 @@ namespace HttpFilters { namespace IpTagging { IpTaggingFilterConfig::IpTaggingFilterConfig( - const envoy::config::filter::http::ip_tagging::v2::IPTagging& config, + const envoy::config::filter::http::ip_tagging::v3alpha::IPTagging& config, const std::string& stat_prefix, Stats::Scope& scope, Runtime::Loader& runtime) : request_type_(requestTypeEnum(config.request_type())), scope_(scope), runtime_(runtime), stat_name_set_(scope.symbolTable().makeSet("IpTagging")), @@ -33,7 +33,7 @@ IpTaggingFilterConfig::IpTaggingFilterConfig( for (const auto& ip_tag : config.ip_tags()) { std::vector cidr_set; cidr_set.reserve(ip_tag.ip_list().size()); - for (const envoy::api::v2::core::CidrRange& entry : ip_tag.ip_list()) { + for (const envoy::api::v3alpha::core::CidrRange& entry : ip_tag.ip_list()) { // Currently, CidrRange::create doesn't guarantee that the CidrRanges are valid. Network::Address::CidrRange cidr_entry = Network::Address::CidrRange::create(entry); diff --git a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h index 95ab46909682..5c000665e8a4 100644 --- a/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h +++ b/source/extensions/filters/http/ip_tagging/ip_tagging_filter.h @@ -7,7 +7,7 @@ #include #include "envoy/common/exception.h" -#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.h" +#include "envoy/config/filter/http/ip_tagging/v3alpha/ip_tagging.pb.h" #include "envoy/http/filter.h" #include "envoy/runtime/runtime.h" #include "envoy/stats/scope.h" @@ -31,7 +31,7 @@ enum class FilterRequestType { INTERNAL, EXTERNAL, BOTH }; */ class IpTaggingFilterConfig { public: - IpTaggingFilterConfig(const envoy::config::filter::http::ip_tagging::v2::IPTagging& config, + IpTaggingFilterConfig(const envoy::config::filter::http::ip_tagging::v3alpha::IPTagging& config, const std::string& stat_prefix, Stats::Scope& scope, Runtime::Loader& runtime); @@ -46,13 +46,13 @@ class IpTaggingFilterConfig { private: static FilterRequestType requestTypeEnum( - envoy::config::filter::http::ip_tagging::v2::IPTagging::RequestType request_type) { + envoy::config::filter::http::ip_tagging::v3alpha::IPTagging::RequestType request_type) { switch (request_type) { - case envoy::config::filter::http::ip_tagging::v2::IPTagging_RequestType_BOTH: + case envoy::config::filter::http::ip_tagging::v3alpha::IPTagging_RequestType_BOTH: return FilterRequestType::BOTH; - case envoy::config::filter::http::ip_tagging::v2::IPTagging_RequestType_INTERNAL: + case envoy::config::filter::http::ip_tagging::v3alpha::IPTagging_RequestType_INTERNAL: return FilterRequestType::INTERNAL; - case envoy::config::filter::http::ip_tagging::v2::IPTagging_RequestType_EXTERNAL: + case envoy::config::filter::http::ip_tagging::v3alpha::IPTagging_RequestType_EXTERNAL: return FilterRequestType::EXTERNAL; default: NOT_REACHED_GCOVR_EXCL_LINE; diff --git a/source/extensions/filters/network/dubbo_proxy/config.cc b/source/extensions/filters/network/dubbo_proxy/config.cc index bc686f42dc1b..249eaa8933f1 100644 --- a/source/extensions/filters/network/dubbo_proxy/config.cc +++ b/source/extensions/filters/network/dubbo_proxy/config.cc @@ -144,7 +144,7 @@ void ConfigImpl::registerFilter(const DubboFilterConfig& proto_config) { Envoy::Config::Utility::getAndCheckFactory( string_name); ProtobufTypes::MessagePtr message = factory.createEmptyConfigProto(); - Envoy::Config::Utility::translateOpaqueConfig(proto_config.config(), + Envoy::Config::Utility::translateOpaqueConfig(string_name, proto_config.config(), ProtobufWkt::Struct::default_instance(), context_.messageValidationVisitor(), *message); DubboFilters::FilterFactoryCb callback = diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index e491d36be307..5b47f1aa5bc3 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -394,7 +394,7 @@ void HttpConnectionManagerConfig::processFilter( Config::Utility::getAndCheckFactory( string_name); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - proto_config, context_.messageValidationVisitor(), factory); + string_name, proto_config, context_.messageValidationVisitor(), factory); Http::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, stats_prefix_, context_); is_terminal = factory.isTerminalFilter(); diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index 88c8adff441b..7e3022834d48 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -166,7 +166,7 @@ void ConfigImpl::processFilter( string_name); ProtobufTypes::MessagePtr message = Envoy::Config::Utility::translateToFactoryConfig( - proto_config, context_.messageValidationVisitor(), factory); + string_name, proto_config, context_.messageValidationVisitor(), factory); ThriftFilters::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, stats_prefix_, context_); diff --git a/source/extensions/grpc_credentials/aws_iam/config.cc b/source/extensions/grpc_credentials/aws_iam/config.cc index b711f4a84427..e102dbb11107 100644 --- a/source/extensions/grpc_credentials/aws_iam/config.cc +++ b/source/extensions/grpc_credentials/aws_iam/config.cc @@ -38,8 +38,8 @@ std::shared_ptr AwsIamGrpcCredentialsFactory::getChann // https://github.com/envoyproxy/envoy/issues/8010. const Envoy::ProtobufTypes::MessagePtr config_message = Envoy::Config::Utility::translateToFactoryConfig( - credential.from_plugin(), ProtobufMessage::getNullValidationVisitor(), - credentials_factory); + credential.from_plugin().name(), credential.from_plugin(), + ProtobufMessage::getNullValidationVisitor(), credentials_factory); const auto& config = Envoy::MessageUtil::downcastAndValidate< const envoy::config::grpc_credential::v2alpha::AwsIamConfig&>( *config_message, ProtobufMessage::getNullValidationVisitor()); diff --git a/source/extensions/grpc_credentials/file_based_metadata/config.cc b/source/extensions/grpc_credentials/file_based_metadata/config.cc index a5ea52a0c923..ba6634974646 100644 --- a/source/extensions/grpc_credentials/file_based_metadata/config.cc +++ b/source/extensions/grpc_credentials/file_based_metadata/config.cc @@ -32,7 +32,8 @@ FileBasedMetadataGrpcCredentialsFactory::getChannelCredentials( // https://github.com/envoyproxy/envoy/issues/8010. const Envoy::ProtobufTypes::MessagePtr file_based_metadata_config_message = Envoy::Config::Utility::translateToFactoryConfig( - credential.from_plugin(), ProtobufMessage::getNullValidationVisitor(), + credential.from_plugin().name(), credential.from_plugin(), + ProtobufMessage::getNullValidationVisitor(), file_based_metadata_credentials_factory); const auto& file_based_metadata_config = Envoy::MessageUtil::downcastAndValidate< const envoy::config::grpc_credential::v2alpha::FileBasedMetadataConfig&>( diff --git a/source/extensions/transport_sockets/tap/config.cc b/source/extensions/transport_sockets/tap/config.cc index fb04ed511b26..799fe81814a9 100644 --- a/source/extensions/transport_sockets/tap/config.cc +++ b/source/extensions/transport_sockets/tap/config.cc @@ -41,7 +41,8 @@ Network::TransportSocketFactoryPtr UpstreamTapSocketConfigFactory::createTranspo Server::Configuration::UpstreamTransportSocketConfigFactory>( outer_config.transport_socket().name()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( - outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); + outer_config.transport_socket().name(), outer_config.transport_socket(), + context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = inner_config_factory.createTransportSocketFactory(*inner_factory_config, context); return std::make_unique( @@ -60,7 +61,8 @@ Network::TransportSocketFactoryPtr DownstreamTapSocketConfigFactory::createTrans Server::Configuration::DownstreamTransportSocketConfigFactory>( outer_config.transport_socket().name()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( - outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); + outer_config.transport_socket().name(), outer_config.transport_socket(), + context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = inner_config_factory.createTransportSocketFactory( *inner_factory_config, context, server_names); return std::make_unique( diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index d0b6315cbda2..cdc91e2cf46e 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -106,7 +106,8 @@ void MainImpl::initializeTracers(const envoy::config::trace::v2::Tracing& config // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory(type); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - configuration.http(), server.messageValidationContext().staticValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + server.messageValidationContext().staticValidationVisitor(), factory); http_tracer_ = factory.createHttpTracer(*message, server); } @@ -118,7 +119,8 @@ void MainImpl::initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstra // Generate factory and translate stats sink custom config auto& factory = Config::Utility::getAndCheckFactory(sink_object.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - sink_object, server.messageValidationContext().staticValidationVisitor(), factory); + sink_object.name(), sink_object, + server.messageValidationContext().staticValidationVisitor(), factory); stats_sinks_.emplace_back(factory.createStatsSink(*message, server)); } diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index a390b3ae0e1e..b5192464ec41 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -143,8 +143,8 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st } auto& config_factory = Config::Utility::getAndCheckFactory( udp_config.udp_listener_name()); - ProtobufTypes::MessagePtr message = - Config::Utility::translateToFactoryConfig(udp_config, validation_visitor_, config_factory); + ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( + udp_config.udp_listener_name(), udp_config, validation_visitor_, config_factory); udp_listener_factory_ = config_factory.createActiveUdpListenerFactory(*message); } diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 3d2ce8bc7546..9410ab0eade7 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -89,7 +89,7 @@ std::vector ProdListenerComponentFactory::createNetwor factory.isTerminalFilter(), i == filters.size() - 1); auto message = Config::Utility::translateToFactoryConfig( - proto_config, context.messageValidationVisitor(), factory); + string_name, proto_config, context.messageValidationVisitor(), factory); Network::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, context); ret.push_back(callback); } @@ -114,7 +114,7 @@ ProdListenerComponentFactory::createListenerFilterFactoryList_( Config::Utility::getAndCheckFactory( string_name); auto message = Config::Utility::translateToFactoryConfig( - proto_config, context.messageValidationVisitor(), factory); + string_name, proto_config, context.messageValidationVisitor(), factory); ret.push_back(factory.createFilterFactoryFromProto(*message, context)); } return ret; @@ -139,7 +139,7 @@ ProdListenerComponentFactory::createUdpListenerFilterFactoryList_( string_name); auto message = Config::Utility::translateToFactoryConfig( - proto_config, context.messageValidationVisitor(), factory); + string_name, proto_config, context.messageValidationVisitor(), factory); ret.push_back(factory.createFilterFactoryFromProto(*message, context)); } return ret; @@ -743,8 +743,9 @@ std::unique_ptr ListenerFilterChainFactoryBuilder::buildFi auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::DownstreamTransportSocketConfigFactory>(transport_socket.name()); - ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - transport_socket, parent_.messageValidationVisitor(), config_factory); + ProtobufTypes::MessagePtr message = + Config::Utility::translateToFactoryConfig(transport_socket.name(), transport_socket, + parent_.messageValidationVisitor(), config_factory); std::vector server_names(filter_chain.filter_chain_match().server_names().begin(), filter_chain.filter_chain_match().server_names().end()); diff --git a/source/server/overload_manager_impl.cc b/source/server/overload_manager_impl.cc index 484be6f075a9..a5c591cccd35 100644 --- a/source/server/overload_manager_impl.cc +++ b/source/server/overload_manager_impl.cc @@ -109,7 +109,8 @@ OverloadManagerImpl::OverloadManagerImpl( ENVOY_LOG(debug, "Adding resource monitor for {}", name); auto& factory = Config::Utility::getAndCheckFactory(name); - auto config = Config::Utility::translateToFactoryConfig(resource, validation_visitor, factory); + auto config = + Config::Utility::translateToFactoryConfig(name, resource, validation_visitor, factory); auto monitor = factory.createResourceMonitor(*config, context); auto result = diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index 059d44313e8c..346c2942a3d6 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1231,7 +1231,7 @@ class TestHeaderFilterFactory : public ExtensionFilterFactory { FilterPtr createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader&, Runtime::RandomGenerator&) override { auto factory_config = Config::Utility::translateToFactoryConfig( - config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); + config.name(), config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); const auto& header_config = TestUtility::downcastAndValidate( *factory_config); @@ -1306,7 +1306,7 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { FilterPtr createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader&, Runtime::RandomGenerator&) override { auto factory_config = Config::Utility::translateToFactoryConfig( - config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); + config.name(), config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); ProtobufWkt::Struct struct_config = *dynamic_cast(factory_config.get()); diff --git a/test/common/config/BUILD b/test/common/config/BUILD index 7367f62e35bb..305dee3e53d6 100644 --- a/test/common/config/BUILD +++ b/test/common/config/BUILD @@ -10,6 +10,16 @@ load( envoy_package() +envoy_cc_test( + name = "api_type_db_test", + srcs = ["api_type_db_test.cc"], + deps = [ + "//source/common/config:api_type_db_lib", + "@envoy_api//envoy/config/filter/http/ip_tagging/v2:pkg_cc_proto", + "@envoy_api//envoy/config/filter/http/ip_tagging/v3alpha:pkg_cc_proto", + ], +) + envoy_cc_test( name = "delta_subscription_impl_test", srcs = ["delta_subscription_impl_test.cc"], diff --git a/test/common/config/api_type_db_test.cc b/test/common/config/api_type_db_test.cc new file mode 100644 index 000000000000..ba9eca9f5736 --- /dev/null +++ b/test/common/config/api_type_db_test.cc @@ -0,0 +1,74 @@ +#include "common/config/api_type_db.h" + +// For proto descriptors only +#include "envoy/config/filter/http/ip_tagging/v2/ip_tagging.pb.h" +#include "envoy/config/filter/http/ip_tagging/v3alpha/ip_tagging.pb.h" + +#include "gtest/gtest.h" +#include "udpa/type/v1/typed_struct.pb.h" + +namespace Envoy { +namespace Config { +namespace { + +TEST(ApiTypeDbTest, All) { + EXPECT_EQ(nullptr, ApiTypeDb::inferEarlierVersionDescriptor("foo", {}, "")); + EXPECT_EQ(nullptr, ApiTypeDb::inferEarlierVersionDescriptor("envoy.ip_tagging", {}, "")); + + // Struct upgrade to v3alpha. + { + const auto* desc = ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", {}, "envoy.config.filter.http.ip_tagging.v3alpha.IPTagging"); + EXPECT_EQ("envoy.config.filter.http.ip_tagging.v2.IPTagging", desc->full_name()); + } + + // Any upgrade from v2 to v3alpha. + { + ProtobufWkt::Any typed_config; + typed_config.set_type_url("envoy.config.filter.http.ip_tagging.v2.IPTagging"); + const auto* desc = ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", typed_config, "envoy.config.filter.http.ip_tagging.v3alpha.IPTagging"); + EXPECT_EQ("envoy.config.filter.http.ip_tagging.v2.IPTagging", desc->full_name()); + } + + // There is no upgrade for same Any and target type URL. + { + ProtobufWkt::Any typed_config; + typed_config.set_type_url("envoy.config.filter.http.ip_tagging.v3alpha.IPTagging"); + EXPECT_EQ(nullptr, ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", typed_config, + "envoy.config.filter.http.ip_tagging.v3alpha.IPTagging")); + } + + // TypedStruct upgrade from v2 to v3alpha. + { + ProtobufWkt::Any typed_config; + udpa::type::v1::TypedStruct typed_struct; + typed_struct.set_type_url("envoy.config.filter.http.ip_tagging.v2.IPTagging"); + typed_config.PackFrom(typed_struct); + const auto* desc = ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", typed_config, "envoy.config.filter.http.ip_tagging.v3alpha.IPTagging"); + EXPECT_EQ("envoy.config.filter.http.ip_tagging.v2.IPTagging", desc->full_name()); + } + + // There is no upgrade for same TypedStruct and target type URL. + { + ProtobufWkt::Any typed_config; + udpa::type::v1::TypedStruct typed_struct; + typed_struct.set_type_url( + "type.googleapis.com/envoy.config.filter.http.ip_tagging.v3alpha.IPTagging"); + typed_config.PackFrom(typed_struct); + EXPECT_EQ(nullptr, ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", typed_config, + "envoy.config.filter.http.ip_tagging.v3alpha.IPTagging")); + } + + // There is no upgrade for v2. + EXPECT_EQ(nullptr, + ApiTypeDb::inferEarlierVersionDescriptor( + "envoy.ip_tagging", {}, "envoy.config.filter.http.ip_tagging.v2.IPTagging")); +} + +} // namespace +} // namespace Config +} // namespace Envoy diff --git a/test/common/config/utility_test.cc b/test/common/config/utility_test.cc index 1fdf0fbeb74a..075f42828e5d 100644 --- a/test/common/config/utility_test.cc +++ b/test/common/config/utility_test.cc @@ -269,7 +269,7 @@ TEST(UtilityTest, AnyWrongType) { typed_config.PackFrom(source_duration); ProtobufWkt::Timestamp out; EXPECT_THROW_WITH_REGEX( - Utility::translateOpaqueConfig(typed_config, ProtobufWkt::Struct(), + Utility::translateOpaqueConfig("", typed_config, ProtobufWkt::Struct(), ProtobufMessage::getStrictValidationVisitor(), out), EnvoyException, R"(Unable to unpack as google.protobuf.Timestamp: \[type.googleapis.com/google.protobuf.Duration\] .*)"); @@ -291,7 +291,7 @@ TEST(UtilityTest, TypedStructToStruct) { packTypedStructIntoAny(typed_config, untyped_struct); ProtobufWkt::Struct out; - Utility::translateOpaqueConfig(typed_config, ProtobufWkt::Struct(), + Utility::translateOpaqueConfig("", typed_config, ProtobufWkt::Struct(), ProtobufMessage::getStrictValidationVisitor(), out); EXPECT_THAT(out, ProtoEq(untyped_struct)); @@ -312,7 +312,7 @@ TEST(UtilityTest, TypedStructToBootstrap) { packTypedStructIntoAny(typed_config, bootstrap); envoy::config::bootstrap::v2::Bootstrap out; - Utility::translateOpaqueConfig(typed_config, ProtobufWkt::Struct(), + Utility::translateOpaqueConfig("", typed_config, ProtobufWkt::Struct(), ProtobufMessage::getStrictValidationVisitor(), out); EXPECT_THAT(out, ProtoEq(bootstrap)); } @@ -333,7 +333,7 @@ TEST(UtilityTest, TypedStructToInvalidType) { ProtobufWkt::Any out; EXPECT_THROW_WITH_MESSAGE( - Utility::translateOpaqueConfig(typed_config, ProtobufWkt::Struct(), + Utility::translateOpaqueConfig("", typed_config, ProtobufWkt::Struct(), ProtobufMessage::getStrictValidationVisitor(), out), EnvoyException, "Invalid proto type.\nExpected google.protobuf.Any\nActual: " diff --git a/test/common/protobuf/utility_test.cc b/test/common/protobuf/utility_test.cc index df8b8c2c19fa..80294460ae29 100644 --- a/test/common/protobuf/utility_test.cc +++ b/test/common/protobuf/utility_test.cc @@ -823,4 +823,10 @@ TEST(StatusCode, Strings) { MessageUtil::CodeEnumToString(static_cast(last_code + 1))); } +TEST(TypeUtilTest, TypeUrlToDescriptorFullName) { + EXPECT_EQ("envoy.config.filter.http.ip_tagging.v2.IPTagging", + TypeUtil::typeUrlToDescriptorFullName( + "type.googleapis.com/envoy.config.filter.http.ip_tagging.v2.IPTagging")); +} + } // namespace Envoy diff --git a/test/extensions/clusters/aggregate/cluster_test.cc b/test/extensions/clusters/aggregate/cluster_test.cc index 83822db98831..bf0c2d5dd6b7 100644 --- a/test/extensions/clusters/aggregate/cluster_test.cc +++ b/test/extensions/clusters/aggregate/cluster_test.cc @@ -72,7 +72,8 @@ class AggregateClusterTest : public testing::Test { void initialize(const std::string& yaml_config) { envoy::api::v2::Cluster cluster_config = Upstream::parseClusterFromV2Yaml(yaml_config); envoy::config::cluster::aggregate::v2alpha::ClusterConfig config; - Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), + Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().name(), + cluster_config.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), ProtobufMessage::getStrictValidationVisitor(), config); Stats::ScopePtr scope = stats_store_.createScope("cluster.name."); diff --git a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc index cc87c48fdde4..3a792f3f604c 100644 --- a/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc +++ b/test/extensions/clusters/dynamic_forward_proxy/cluster_test.cc @@ -26,7 +26,8 @@ class ClusterTest : public testing::Test, void initialize(const std::string& yaml_config, bool uses_tls) { envoy::api::v2::Cluster cluster_config = Upstream::parseClusterFromV2Yaml(yaml_config); envoy::config::cluster::dynamic_forward_proxy::v2alpha::ClusterConfig config; - Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), + Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().name(), + cluster_config.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), ProtobufMessage::getStrictValidationVisitor(), config); Stats::ScopePtr scope = stats_store_.createScope("cluster.name."); diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index b0179a1d887e..73c72f9d332f 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -92,7 +92,8 @@ class RedisClusterTest : public testing::Test, singleton_manager_, tls_, validation_visitor_, *api_); envoy::config::cluster::redis::RedisClusterConfig config; - Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), + Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().name(), + cluster_config.cluster_type().typed_config(), ProtobufWkt::Struct::default_instance(), ProtobufMessage::getStrictValidationVisitor(), config); cluster_callback_ = std::make_shared>(); @@ -122,9 +123,9 @@ class RedisClusterTest : public testing::Test, singleton_manager_, tls_, validation_visitor_, *api_); envoy::config::cluster::redis::RedisClusterConfig config; - Config::Utility::translateOpaqueConfig(cluster_config.cluster_type().typed_config(), - ProtobufWkt::Struct::default_instance(), - validation_visitor_, config); + Config::Utility::translateOpaqueConfig( + cluster_config.cluster_type().name(), cluster_config.cluster_type().typed_config(), + ProtobufWkt::Struct::default_instance(), validation_visitor_, config); NiceMock log_manager; NiceMock outlier_event_logger; diff --git a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc index 4c490321c40c..a237eb08a1de 100644 --- a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc +++ b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc @@ -41,7 +41,7 @@ request_type: internal )EOF"; void initializeFilter(const std::string& yaml) { - envoy::config::filter::http::ip_tagging::v2::IPTagging config; + envoy::config::filter::http::ip_tagging::v3alpha::IPTagging config; TestUtility::loadFromYaml(yaml, config); config_.reset(new IpTaggingFilterConfig(config, "prefix.", stats_, runtime_)); filter_ = std::make_unique(config_); diff --git a/test/extensions/tracers/datadog/config_test.cc b/test/extensions/tracers/datadog/config_test.cc index 9ffe6a003561..c98e51741d8d 100644 --- a/test/extensions/tracers/datadog/config_test.cc +++ b/test/extensions/tracers/datadog/config_test.cc @@ -34,7 +34,8 @@ TEST(DatadogTracerConfigTest, DatadogHttpTracer) { DatadogTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr datadog_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, datadog_tracer); } diff --git a/test/extensions/tracers/dynamic_ot/config_test.cc b/test/extensions/tracers/dynamic_ot/config_test.cc index 5c11d6172f69..4117589c7fde 100644 --- a/test/extensions/tracers/dynamic_ot/config_test.cc +++ b/test/extensions/tracers/dynamic_ot/config_test.cc @@ -39,7 +39,8 @@ TEST(DynamicOtTracerConfigTest, DynamicOpentracingHttpTracer) { DynamicOpenTracingTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); const Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); } diff --git a/test/extensions/tracers/lightstep/config_test.cc b/test/extensions/tracers/lightstep/config_test.cc index 7cdd4595ef3e..c686b88f5ecc 100644 --- a/test/extensions/tracers/lightstep/config_test.cc +++ b/test/extensions/tracers/lightstep/config_test.cc @@ -34,7 +34,8 @@ TEST(LightstepTracerConfigTest, LightstepHttpTracer) { LightstepTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr lightstep_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, lightstep_tracer); } diff --git a/test/extensions/tracers/opencensus/config_test.cc b/test/extensions/tracers/opencensus/config_test.cc index 95cd8767f86b..857184612fa3 100644 --- a/test/extensions/tracers/opencensus/config_test.cc +++ b/test/extensions/tracers/opencensus/config_test.cc @@ -26,7 +26,8 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracer) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); } @@ -64,7 +65,8 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerWithTypedConfig) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); diff --git a/test/extensions/tracers/xray/config_test.cc b/test/extensions/tracers/xray/config_test.cc index 91dcd5903a0d..1b372a8943b4 100644 --- a/test/extensions/tracers/xray/config_test.cc +++ b/test/extensions/tracers/xray/config_test.cc @@ -34,7 +34,8 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithTypedConfig) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr xray_tracer = factory.createHttpTracer(*message, server); ASSERT_NE(nullptr, xray_tracer); } @@ -65,7 +66,8 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithInvalidFileName) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr xray_tracer = factory.createHttpTracer(*message, server); ASSERT_NE(nullptr, xray_tracer); diff --git a/test/extensions/tracers/zipkin/config_test.cc b/test/extensions/tracers/zipkin/config_test.cc index 750596655291..409ae03ee3cc 100644 --- a/test/extensions/tracers/zipkin/config_test.cc +++ b/test/extensions/tracers/zipkin/config_test.cc @@ -35,7 +35,8 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracer) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr zipkin_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, zipkin_tracer); } @@ -61,7 +62,8 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracerWithTypedConfig) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http().name(), configuration.http(), + ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr zipkin_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, zipkin_tracer); } diff --git a/test/integration/BUILD b/test/integration/BUILD index 233eab357812..65f9e6dc1611 100644 --- a/test/integration/BUILD +++ b/test/integration/BUILD @@ -799,6 +799,15 @@ envoy_cc_test( ], ) +envoy_cc_test( + name = "version_integration_test", + srcs = ["version_integration_test.cc"], + deps = [ + ":http_integration_lib", + "//source/extensions/filters/http/ip_tagging:config", + ], +) + envoy_cc_test( name = "dynamic_validation_integration_test", srcs = ["dynamic_validation_integration_test.cc"], diff --git a/test/integration/version_integration_test.cc b/test/integration/version_integration_test.cc new file mode 100644 index 000000000000..c083ba3bbe63 --- /dev/null +++ b/test/integration/version_integration_test.cc @@ -0,0 +1,86 @@ +#include "test/integration/http_integration.h" + +namespace Envoy { +namespace { + +// Integration test for ingestion of configuraiton across API versions. +// Currently we only have static tests, but there will also be xDS tests added +// later. +class VersionIntegrationTest : public testing::TestWithParam, + public HttpIntegrationTest { +public: + VersionIntegrationTest() : HttpIntegrationTest(Http::CodecClient::Type::HTTP1, GetParam()) {} +}; + +INSTANTIATE_TEST_SUITE_P(IpVersions, VersionIntegrationTest, + testing::ValuesIn(TestEnvironment::getIpVersionsForTest())); + +// Just IP tagging for now. +const char ExampleIpTaggingConfig[] = R"EOF( + request_type: both + ip_tags: + - ip_tag_name: external_request + ip_list: + - {address_prefix: 1.2.3.4, prefix_len: 32} +)EOF"; + +// envoy.ip_tagging from v2 Struct config. +TEST_P(VersionIntegrationTest, IpTaggingV2StaticStructConfig) { + config_helper_.addFilter(absl::StrCat(R"EOF( + name: envoy.ip_tagging + config: + )EOF", + ExampleIpTaggingConfig)); + initialize(); +} + +// envoy.ip_tagging from v2 TypedStruct config. +TEST_P(VersionIntegrationTest, IpTaggingV2StaticTypedStructConfig) { + config_helper_.addFilter(absl::StrCat(R"EOF( +name: envoy.ip_tagging +typed_config: + "@type": type.googleapis.com/udpa.type.v1.TypedStruct + type_url: type.googleapis.com/envoy.config.filter.http.ip_tagging.v2.IPTagging + value: + )EOF", + ExampleIpTaggingConfig)); + initialize(); +} + +// envoy.ip_tagging from v3alpha TypedStruct config. +TEST_P(VersionIntegrationTest, IpTaggingV3AlphaStaticTypedStructConfig) { + config_helper_.addFilter(absl::StrCat(R"EOF( +name: envoy.ip_tagging +typed_config: + "@type": type.googleapis.com/udpa.type.v1.TypedStruct + type_url: type.googleapis.com/envoy.config.filter.http.ip_tagging.v3alpha.IPTagging + value: + )EOF", + ExampleIpTaggingConfig)); + initialize(); +} + +// envoy.ip_tagging from v2 typed Any config. +TEST_P(VersionIntegrationTest, IpTaggingV2StaticTypedConfig) { + config_helper_.addFilter(absl::StrCat(R"EOF( + name: envoy.ip_tagging + typed_config: + "@type": type.googleapis.com/envoy.config.filter.http.ip_tagging.v2.IPTagging + )EOF", + ExampleIpTaggingConfig)); + initialize(); +} + +// envoy.ip_tagging from v3alpha typed Any config. +TEST_P(VersionIntegrationTest, IpTaggingV3AlphaStaticTypedConfig) { + config_helper_.addFilter(absl::StrCat(R"EOF( + name: envoy.ip_tagging + typed_config: + "@type": type.googleapis.com/envoy.config.filter.http.ip_tagging.v3alpha.IPTagging + )EOF", + ExampleIpTaggingConfig)); + initialize(); +} + +} // namespace +} // namespace Envoy From 037dcff853a8c381d26996235e1b3ba3f39e2013 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Wed, 27 Nov 2019 06:11:57 -0500 Subject: [PATCH 2/4] Nit. Signed-off-by: Harvey Tuch --- source/common/protobuf/utility.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/protobuf/utility.cc b/source/common/protobuf/utility.cc index b5bcfd93bd22..914f33e78b5e 100644 --- a/source/common/protobuf/utility.cc +++ b/source/common/protobuf/utility.cc @@ -614,7 +614,7 @@ void TimestampUtil::systemClockToTimestamp(const SystemTime system_clock_time, } absl::string_view TypeUtil::typeUrlToDescriptorFullName(absl::string_view type_url) { - size_t pos = type_url.find_last_of('/'); + const size_t pos = type_url.rfind('/'); if (pos != absl::string_view::npos) { type_url = type_url.substr(pos + 1); } From 070a6b238e6b43bef79806db942231146aa98cbf Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Wed, 27 Nov 2019 06:20:40 -0500 Subject: [PATCH 3/4] Use factory.name() to simplify translateToFactoryConfig(). Signed-off-by: Harvey Tuch --- source/common/access_log/access_log_impl.cc | 2 +- source/common/config/api_type_db.h | 2 +- source/common/config/utility.h | 4 ++-- source/common/router/config_impl.cc | 9 ++++----- source/common/upstream/transport_socket_match_impl.cc | 3 +-- source/common/upstream/upstream_impl.cc | 3 +-- .../filters/network/http_connection_manager/config.cc | 2 +- .../extensions/filters/network/thrift_proxy/config.cc | 2 +- source/extensions/grpc_credentials/aws_iam/config.cc | 4 ++-- .../grpc_credentials/file_based_metadata/config.cc | 3 +-- source/extensions/transport_sockets/tap/config.cc | 6 ++---- source/server/configuration_impl.cc | 6 ++---- source/server/listener_impl.cc | 4 ++-- source/server/listener_manager_impl.cc | 11 +++++------ source/server/overload_manager_impl.cc | 3 +-- test/common/access_log/access_log_impl_test.cc | 4 ++-- test/extensions/tracers/datadog/config_test.cc | 3 +-- test/extensions/tracers/dynamic_ot/config_test.cc | 3 +-- test/extensions/tracers/lightstep/config_test.cc | 3 +-- test/extensions/tracers/opencensus/config_test.cc | 6 ++---- test/extensions/tracers/xray/config_test.cc | 6 ++---- test/extensions/tracers/zipkin/config_test.cc | 6 ++---- test/integration/version_integration_test.cc | 2 +- 23 files changed, 39 insertions(+), 58 deletions(-) diff --git a/source/common/access_log/access_log_impl.cc b/source/common/access_log/access_log_impl.cc index 8db2520a58e5..7613e3ba9ae0 100644 --- a/source/common/access_log/access_log_impl.cc +++ b/source/common/access_log/access_log_impl.cc @@ -279,7 +279,7 @@ AccessLogFactory::fromProto(const envoy::config::filter::accesslog::v2::AccessLo Config::Utility::getAndCheckFactory( config.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - config.name(), config, context.messageValidationVisitor(), factory); + config, context.messageValidationVisitor(), factory); return factory.createAccessLogInstance(*message, std::move(filter), context); } diff --git a/source/common/config/api_type_db.h b/source/common/config/api_type_db.h index defbec45c086..ae6009dbc6e0 100644 --- a/source/common/config/api_type_db.h +++ b/source/common/config/api_type_db.h @@ -19,7 +19,7 @@ class ApiTypeDb { * @param typed_config opaque config packed in google.protobuf.Any. * @param target_type target type of conversion. * @return const Protobuf::Descriptor* descriptor for earlier message version - * corresponding to config, if any, otherwise nulllptr. + * corresponding to config, if any, otherwise nullptr. */ static const Protobuf::Descriptor* inferEarlierVersionDescriptor(absl::string_view extension_name, diff --git a/source/common/config/utility.h b/source/common/config/utility.h index e6edfbf1add5..8e8c25a52293 100644 --- a/source/common/config/utility.h +++ b/source/common/config/utility.h @@ -218,7 +218,7 @@ class Utility { */ template static ProtobufTypes::MessagePtr - translateToFactoryConfig(absl::string_view extension_name, const ProtoMessage& enclosing_message, + translateToFactoryConfig(const ProtoMessage& enclosing_message, ProtobufMessage::ValidationVisitor& validation_visitor, Factory& factory) { ProtobufTypes::MessagePtr config = factory.createEmptyConfigProto(); @@ -226,7 +226,7 @@ class Utility { // Fail in an obvious way if a plugin does not return a proto. RELEASE_ASSERT(config != nullptr, ""); - translateOpaqueConfig(extension_name, enclosing_message.typed_config(), + translateOpaqueConfig(factory.name(), enclosing_message.typed_config(), enclosing_message.config(), validation_visitor, *config); return config; diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 903fc124c0fd..c3c59669a2f5 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -79,8 +79,8 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry for (const auto& host_predicate : retry_policy.retry_host_predicate()) { auto& factory = Envoy::Config::Utility::getAndCheckFactory( host_predicate.name()); - auto config = Envoy::Config::Utility::translateToFactoryConfig( - host_predicate.name(), host_predicate, validation_visitor, factory); + auto config = Envoy::Config::Utility::translateToFactoryConfig(host_predicate, + validation_visitor, factory); retry_host_predicate_configs_.emplace_back(host_predicate.name(), std::move(config)); } @@ -89,9 +89,8 @@ RetryPolicyImpl::RetryPolicyImpl(const envoy::api::v2::route::RetryPolicy& retry auto& factory = Envoy::Config::Utility::getAndCheckFactory( retry_priority.name()); retry_priority_config_ = - std::make_pair(retry_priority.name(), - Envoy::Config::Utility::translateToFactoryConfig( - retry_priority.name(), retry_priority, validation_visitor, factory)); + std::make_pair(retry_priority.name(), Envoy::Config::Utility::translateToFactoryConfig( + retry_priority, validation_visitor, factory)); } auto host_selection_attempts = retry_policy.host_selection_retry_max_attempts(); diff --git a/source/common/upstream/transport_socket_match_impl.cc b/source/common/upstream/transport_socket_match_impl.cc index 7a300a45c91b..1b99435cb0d0 100644 --- a/source/common/upstream/transport_socket_match_impl.cc +++ b/source/common/upstream/transport_socket_match_impl.cc @@ -18,8 +18,7 @@ TransportSocketMatcherImpl::TransportSocketMatcherImpl( auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::UpstreamTransportSocketConfigFactory>(socket_config.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - socket_config.name(), socket_config, factory_context.messageValidationVisitor(), - config_factory); + socket_config, factory_context.messageValidationVisitor(), config_factory); FactoryMatch factory_match( socket_match.name(), config_factory.createTransportSocketFactory(*message, factory_context), generateStats(socket_match.name() + ".")); diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index ab1b47ca8df3..26f51bd8b7ae 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -791,8 +791,7 @@ Network::TransportSocketFactoryPtr createTransportSocketFactory( auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::UpstreamTransportSocketConfigFactory>(transport_socket.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - transport_socket.name(), transport_socket, factory_context.messageValidationVisitor(), - config_factory); + transport_socket, factory_context.messageValidationVisitor(), config_factory); return config_factory.createTransportSocketFactory(*message, factory_context); } diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 5b47f1aa5bc3..e491d36be307 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -394,7 +394,7 @@ void HttpConnectionManagerConfig::processFilter( Config::Utility::getAndCheckFactory( string_name); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - string_name, proto_config, context_.messageValidationVisitor(), factory); + proto_config, context_.messageValidationVisitor(), factory); Http::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, stats_prefix_, context_); is_terminal = factory.isTerminalFilter(); diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index 7e3022834d48..88c8adff441b 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -166,7 +166,7 @@ void ConfigImpl::processFilter( string_name); ProtobufTypes::MessagePtr message = Envoy::Config::Utility::translateToFactoryConfig( - string_name, proto_config, context_.messageValidationVisitor(), factory); + proto_config, context_.messageValidationVisitor(), factory); ThriftFilters::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, stats_prefix_, context_); diff --git a/source/extensions/grpc_credentials/aws_iam/config.cc b/source/extensions/grpc_credentials/aws_iam/config.cc index e102dbb11107..b711f4a84427 100644 --- a/source/extensions/grpc_credentials/aws_iam/config.cc +++ b/source/extensions/grpc_credentials/aws_iam/config.cc @@ -38,8 +38,8 @@ std::shared_ptr AwsIamGrpcCredentialsFactory::getChann // https://github.com/envoyproxy/envoy/issues/8010. const Envoy::ProtobufTypes::MessagePtr config_message = Envoy::Config::Utility::translateToFactoryConfig( - credential.from_plugin().name(), credential.from_plugin(), - ProtobufMessage::getNullValidationVisitor(), credentials_factory); + credential.from_plugin(), ProtobufMessage::getNullValidationVisitor(), + credentials_factory); const auto& config = Envoy::MessageUtil::downcastAndValidate< const envoy::config::grpc_credential::v2alpha::AwsIamConfig&>( *config_message, ProtobufMessage::getNullValidationVisitor()); diff --git a/source/extensions/grpc_credentials/file_based_metadata/config.cc b/source/extensions/grpc_credentials/file_based_metadata/config.cc index ba6634974646..a5ea52a0c923 100644 --- a/source/extensions/grpc_credentials/file_based_metadata/config.cc +++ b/source/extensions/grpc_credentials/file_based_metadata/config.cc @@ -32,8 +32,7 @@ FileBasedMetadataGrpcCredentialsFactory::getChannelCredentials( // https://github.com/envoyproxy/envoy/issues/8010. const Envoy::ProtobufTypes::MessagePtr file_based_metadata_config_message = Envoy::Config::Utility::translateToFactoryConfig( - credential.from_plugin().name(), credential.from_plugin(), - ProtobufMessage::getNullValidationVisitor(), + credential.from_plugin(), ProtobufMessage::getNullValidationVisitor(), file_based_metadata_credentials_factory); const auto& file_based_metadata_config = Envoy::MessageUtil::downcastAndValidate< const envoy::config::grpc_credential::v2alpha::FileBasedMetadataConfig&>( diff --git a/source/extensions/transport_sockets/tap/config.cc b/source/extensions/transport_sockets/tap/config.cc index 799fe81814a9..fb04ed511b26 100644 --- a/source/extensions/transport_sockets/tap/config.cc +++ b/source/extensions/transport_sockets/tap/config.cc @@ -41,8 +41,7 @@ Network::TransportSocketFactoryPtr UpstreamTapSocketConfigFactory::createTranspo Server::Configuration::UpstreamTransportSocketConfigFactory>( outer_config.transport_socket().name()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( - outer_config.transport_socket().name(), outer_config.transport_socket(), - context.messageValidationVisitor(), inner_config_factory); + outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = inner_config_factory.createTransportSocketFactory(*inner_factory_config, context); return std::make_unique( @@ -61,8 +60,7 @@ Network::TransportSocketFactoryPtr DownstreamTapSocketConfigFactory::createTrans Server::Configuration::DownstreamTransportSocketConfigFactory>( outer_config.transport_socket().name()); ProtobufTypes::MessagePtr inner_factory_config = Config::Utility::translateToFactoryConfig( - outer_config.transport_socket().name(), outer_config.transport_socket(), - context.messageValidationVisitor(), inner_config_factory); + outer_config.transport_socket(), context.messageValidationVisitor(), inner_config_factory); auto inner_transport_factory = inner_config_factory.createTransportSocketFactory( *inner_factory_config, context, server_names); return std::make_unique( diff --git a/source/server/configuration_impl.cc b/source/server/configuration_impl.cc index cdc91e2cf46e..d0b6315cbda2 100644 --- a/source/server/configuration_impl.cc +++ b/source/server/configuration_impl.cc @@ -106,8 +106,7 @@ void MainImpl::initializeTracers(const envoy::config::trace::v2::Tracing& config // Now see if there is a factory that will accept the config. auto& factory = Config::Utility::getAndCheckFactory(type); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - server.messageValidationContext().staticValidationVisitor(), factory); + configuration.http(), server.messageValidationContext().staticValidationVisitor(), factory); http_tracer_ = factory.createHttpTracer(*message, server); } @@ -119,8 +118,7 @@ void MainImpl::initializeStatsSinks(const envoy::config::bootstrap::v2::Bootstra // Generate factory and translate stats sink custom config auto& factory = Config::Utility::getAndCheckFactory(sink_object.name()); ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - sink_object.name(), sink_object, - server.messageValidationContext().staticValidationVisitor(), factory); + sink_object, server.messageValidationContext().staticValidationVisitor(), factory); stats_sinks_.emplace_back(factory.createStatsSink(*message, server)); } diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index b5192464ec41..a390b3ae0e1e 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -143,8 +143,8 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st } auto& config_factory = Config::Utility::getAndCheckFactory( udp_config.udp_listener_name()); - ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( - udp_config.udp_listener_name(), udp_config, validation_visitor_, config_factory); + ProtobufTypes::MessagePtr message = + Config::Utility::translateToFactoryConfig(udp_config, validation_visitor_, config_factory); udp_listener_factory_ = config_factory.createActiveUdpListenerFactory(*message); } diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 9410ab0eade7..3d2ce8bc7546 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -89,7 +89,7 @@ std::vector ProdListenerComponentFactory::createNetwor factory.isTerminalFilter(), i == filters.size() - 1); auto message = Config::Utility::translateToFactoryConfig( - string_name, proto_config, context.messageValidationVisitor(), factory); + proto_config, context.messageValidationVisitor(), factory); Network::FilterFactoryCb callback = factory.createFilterFactoryFromProto(*message, context); ret.push_back(callback); } @@ -114,7 +114,7 @@ ProdListenerComponentFactory::createListenerFilterFactoryList_( Config::Utility::getAndCheckFactory( string_name); auto message = Config::Utility::translateToFactoryConfig( - string_name, proto_config, context.messageValidationVisitor(), factory); + proto_config, context.messageValidationVisitor(), factory); ret.push_back(factory.createFilterFactoryFromProto(*message, context)); } return ret; @@ -139,7 +139,7 @@ ProdListenerComponentFactory::createUdpListenerFilterFactoryList_( string_name); auto message = Config::Utility::translateToFactoryConfig( - string_name, proto_config, context.messageValidationVisitor(), factory); + proto_config, context.messageValidationVisitor(), factory); ret.push_back(factory.createFilterFactoryFromProto(*message, context)); } return ret; @@ -743,9 +743,8 @@ std::unique_ptr ListenerFilterChainFactoryBuilder::buildFi auto& config_factory = Config::Utility::getAndCheckFactory< Server::Configuration::DownstreamTransportSocketConfigFactory>(transport_socket.name()); - ProtobufTypes::MessagePtr message = - Config::Utility::translateToFactoryConfig(transport_socket.name(), transport_socket, - parent_.messageValidationVisitor(), config_factory); + ProtobufTypes::MessagePtr message = Config::Utility::translateToFactoryConfig( + transport_socket, parent_.messageValidationVisitor(), config_factory); std::vector server_names(filter_chain.filter_chain_match().server_names().begin(), filter_chain.filter_chain_match().server_names().end()); diff --git a/source/server/overload_manager_impl.cc b/source/server/overload_manager_impl.cc index a5c591cccd35..484be6f075a9 100644 --- a/source/server/overload_manager_impl.cc +++ b/source/server/overload_manager_impl.cc @@ -109,8 +109,7 @@ OverloadManagerImpl::OverloadManagerImpl( ENVOY_LOG(debug, "Adding resource monitor for {}", name); auto& factory = Config::Utility::getAndCheckFactory(name); - auto config = - Config::Utility::translateToFactoryConfig(name, resource, validation_visitor, factory); + auto config = Config::Utility::translateToFactoryConfig(resource, validation_visitor, factory); auto monitor = factory.createResourceMonitor(*config, context); auto result = diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index 346c2942a3d6..059d44313e8c 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1231,7 +1231,7 @@ class TestHeaderFilterFactory : public ExtensionFilterFactory { FilterPtr createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader&, Runtime::RandomGenerator&) override { auto factory_config = Config::Utility::translateToFactoryConfig( - config.name(), config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); + config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); const auto& header_config = TestUtility::downcastAndValidate( *factory_config); @@ -1306,7 +1306,7 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { FilterPtr createFilter(const envoy::config::filter::accesslog::v2::ExtensionFilter& config, Runtime::Loader&, Runtime::RandomGenerator&) override { auto factory_config = Config::Utility::translateToFactoryConfig( - config.name(), config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); + config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); ProtobufWkt::Struct struct_config = *dynamic_cast(factory_config.get()); diff --git a/test/extensions/tracers/datadog/config_test.cc b/test/extensions/tracers/datadog/config_test.cc index c98e51741d8d..9ffe6a003561 100644 --- a/test/extensions/tracers/datadog/config_test.cc +++ b/test/extensions/tracers/datadog/config_test.cc @@ -34,8 +34,7 @@ TEST(DatadogTracerConfigTest, DatadogHttpTracer) { DatadogTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr datadog_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, datadog_tracer); } diff --git a/test/extensions/tracers/dynamic_ot/config_test.cc b/test/extensions/tracers/dynamic_ot/config_test.cc index 4117589c7fde..5c11d6172f69 100644 --- a/test/extensions/tracers/dynamic_ot/config_test.cc +++ b/test/extensions/tracers/dynamic_ot/config_test.cc @@ -39,8 +39,7 @@ TEST(DynamicOtTracerConfigTest, DynamicOpentracingHttpTracer) { DynamicOpenTracingTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); const Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); } diff --git a/test/extensions/tracers/lightstep/config_test.cc b/test/extensions/tracers/lightstep/config_test.cc index c686b88f5ecc..7cdd4595ef3e 100644 --- a/test/extensions/tracers/lightstep/config_test.cc +++ b/test/extensions/tracers/lightstep/config_test.cc @@ -34,8 +34,7 @@ TEST(LightstepTracerConfigTest, LightstepHttpTracer) { LightstepTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr lightstep_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, lightstep_tracer); } diff --git a/test/extensions/tracers/opencensus/config_test.cc b/test/extensions/tracers/opencensus/config_test.cc index 857184612fa3..95cd8767f86b 100644 --- a/test/extensions/tracers/opencensus/config_test.cc +++ b/test/extensions/tracers/opencensus/config_test.cc @@ -26,8 +26,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracer) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); } @@ -65,8 +64,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerWithTypedConfig) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, tracer); diff --git a/test/extensions/tracers/xray/config_test.cc b/test/extensions/tracers/xray/config_test.cc index 1b372a8943b4..91dcd5903a0d 100644 --- a/test/extensions/tracers/xray/config_test.cc +++ b/test/extensions/tracers/xray/config_test.cc @@ -34,8 +34,7 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithTypedConfig) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr xray_tracer = factory.createHttpTracer(*message, server); ASSERT_NE(nullptr, xray_tracer); } @@ -66,8 +65,7 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithInvalidFileName) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr xray_tracer = factory.createHttpTracer(*message, server); ASSERT_NE(nullptr, xray_tracer); diff --git a/test/extensions/tracers/zipkin/config_test.cc b/test/extensions/tracers/zipkin/config_test.cc index 409ae03ee3cc..750596655291 100644 --- a/test/extensions/tracers/zipkin/config_test.cc +++ b/test/extensions/tracers/zipkin/config_test.cc @@ -35,8 +35,7 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracer) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr zipkin_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, zipkin_tracer); } @@ -62,8 +61,7 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracerWithTypedConfig) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( - configuration.http().name(), configuration.http(), - ProtobufMessage::getStrictValidationVisitor(), factory); + configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); Tracing::HttpTracerPtr zipkin_tracer = factory.createHttpTracer(*message, server); EXPECT_NE(nullptr, zipkin_tracer); } diff --git a/test/integration/version_integration_test.cc b/test/integration/version_integration_test.cc index c083ba3bbe63..d6ad924dff71 100644 --- a/test/integration/version_integration_test.cc +++ b/test/integration/version_integration_test.cc @@ -3,7 +3,7 @@ namespace Envoy { namespace { -// Integration test for ingestion of configuraiton across API versions. +// Integration test for ingestion of configuration across API versions. // Currently we only have static tests, but there will also be xDS tests added // later. class VersionIntegrationTest : public testing::TestWithParam, From 60d80e068a005954c24eafae8c9383a9732a86a2 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Wed, 27 Nov 2019 12:25:46 -0500 Subject: [PATCH 4/4] DEPRECATED_FEATURE_TEST Signed-off-by: Harvey Tuch --- test/integration/version_integration_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/version_integration_test.cc b/test/integration/version_integration_test.cc index d6ad924dff71..e5d09ff9a41e 100644 --- a/test/integration/version_integration_test.cc +++ b/test/integration/version_integration_test.cc @@ -25,7 +25,7 @@ const char ExampleIpTaggingConfig[] = R"EOF( )EOF"; // envoy.ip_tagging from v2 Struct config. -TEST_P(VersionIntegrationTest, IpTaggingV2StaticStructConfig) { +TEST_P(VersionIntegrationTest, DEPRECATED_FEATURE_TEST(IpTaggingV2StaticStructConfig)) { config_helper_.addFilter(absl::StrCat(R"EOF( name: envoy.ip_tagging config: