Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7448070
Adding xDS RDS support for thrift protocol.
Aug 9, 2021
eb5dc21
Fix generated_api_shadow
Aug 11, 2021
fcc2abf
Merge main
Aug 11, 2021
d1e2124
Fix missed file
Aug 11, 2021
4609c02
Fix conn_manager_test
Aug 11, 2021
f48daed
Fix router_ratelimit_test
Aug 11, 2021
0022eed
Fix clang_tidy
Aug 12, 2021
3235184
More type urls can identify the same RouteDiscoveryService endpoint
Aug 18, 2021
12aa485
Merge branch 'main' into add_thrift_rds
Aug 18, 2021
6506f20
Fix merge conflict resolution, add test
Aug 21, 2021
e9bb514
Dummy
Aug 21, 2021
b95bf8e
Merge branch 'main' into add_thrift_rds
Sep 26, 2021
fbf27dc
Template base classes for rds handling.
Sep 10, 2021
cd88857
Merge branch 'main' into add_thrift_rds_rework
Sep 28, 2021
aeb9476
Fix RouteConfigUpdateReceiverImpl::onVhdsUpdate
Sep 29, 2021
7811138
Fix clang-tidy errors
Oct 2, 2021
508f711
Fix clang-tidy errors, missing build dependencies
Oct 3, 2021
c28ff34
Merge branch 'main' into add_thrift_rds_rework
Oct 3, 2021
8ca0a4f
Debug strange lua filter coverage issue
Oct 4, 2021
639148d
Revert: Debug strange lua filter coverage issue
Oct 4, 2021
054460e
Separate service endpoint to Thrift rds
Oct 5, 2021
0695c52
Move service to thrift rds into api/envoy/services
Oct 7, 2021
15e1747
Kick CI
Oct 7, 2021
f6f111c
Simplifications
Oct 10, 2021
4414291
Merge branch 'main' into add_thrift_rds
Oct 11, 2021
b9ab26f
Add prefix to Thrift rds related proto names in the api.
Oct 12, 2021
44f9ea8
Fix missed file
Oct 12, 2021
4ae0e46
Kick CI
Oct 13, 2021
ab9e419
Kick CI
Oct 14, 2021
bbc830b
Change TRDS method names similar to other DS method names
Oct 16, 2021
cd7c2d7
Fix ut
Oct 17, 2021
8e9dbea
Merge branch 'main' into add_thrift_rds
Oct 18, 2021
7d93eb6
Eliminate templates from generic rds base classes.
Oct 28, 2021
22d91c7
Fix CI issues.
Oct 28, 2021
54090b2
Fix CI issues.
Oct 29, 2021
2e94bda
Fix CI issues.
Oct 30, 2021
d8b377f
Fix CI issues.
Oct 30, 2021
8209da5
Fix CI issues, clang-tidy.
Oct 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";

package envoy.extensions.filters.network.thrift_proxy.v3;

import "envoy/config/core/v3/config_source.proto";
import "envoy/extensions/filters/network/thrift_proxy/v3/route.proto";

import "google/protobuf/any.proto";
Expand Down Expand Up @@ -58,7 +59,7 @@ enum ProtocolType {
TWITTER = 4;
}

// [#next-free-field: 8]
// [#next-free-field: 9]
message ThriftProxy {
option (udpa.annotations.versioning).previous_message_type =
"envoy.config.filter.network.thrift_proxy.v2alpha1.ThriftProxy";
Expand Down Expand Up @@ -92,6 +93,9 @@ message ThriftProxy {

// Optional maximum requests for a single downstream connection. If not specified, there is no limit.
google.protobuf.UInt32Value max_requests_per_connection = 7;

// Use xDS to fetch the route configuration. If both route_config and rds defined, rds has priority.
Rds rds = 8;
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
}

// ThriftFilter configures a Thrift filter.
Expand Down Expand Up @@ -138,3 +142,9 @@ message ThriftProtocolOptions {
// which is the default, causes the proxy to use the same protocol as the downstream connection.
ProtocolType protocol = 2 [(validate.rules).enum = {defined_only: true}];
}

message Rds {
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
config.core.v3.ConfigSource config_source = 1 [(validate.rules).message = {required: true}];

string route_config_name = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";

package envoy.extensions.filters.network.thrift_proxy.v4alpha;

import "envoy/config/core/v4alpha/config_source.proto";
import "envoy/extensions/filters/network/thrift_proxy/v4alpha/route.proto";

import "google/protobuf/any.proto";
Expand Down Expand Up @@ -58,7 +59,7 @@ enum ProtocolType {
TWITTER = 4;
}

// [#next-free-field: 8]
// [#next-free-field: 9]
message ThriftProxy {
option (udpa.annotations.versioning).previous_message_type =
"envoy.extensions.filters.network.thrift_proxy.v3.ThriftProxy";
Expand Down Expand Up @@ -92,6 +93,9 @@ message ThriftProxy {

// Optional maximum requests for a single downstream connection. If not specified, there is no limit.
google.protobuf.UInt32Value max_requests_per_connection = 7;

// Use xDS to fetch the route configuration. If both route_config and rds defined, rds has priority.
Rds rds = 8;
}

// ThriftFilter configures a Thrift filter.
Expand Down Expand Up @@ -138,3 +142,12 @@ message ThriftProtocolOptions {
// which is the default, causes the proxy to use the same protocol as the downstream connection.
ProtocolType protocol = 2 [(validate.rules).enum = {defined_only: true}];
}

message Rds {
option (udpa.annotations.versioning).previous_message_type =
"envoy.extensions.filters.network.thrift_proxy.v3.Rds";

config.core.v4alpha.ConfigSource config_source = 1 [(validate.rules).message = {required: true}];

string route_config_name = 2;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions source/extensions/filters/network/thrift_proxy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ envoy_cc_extension(
"//source/extensions/filters/network:well_known_names",
"//source/extensions/filters/network/common:factory_base_lib",
"//source/extensions/filters/network/thrift_proxy/filters:filter_config_interface",
"//source/extensions/filters/network/thrift_proxy/router:rds_lib",
"//source/extensions/filters/network/thrift_proxy/router:router_lib",
"@envoy_api//envoy/extensions/filters/network/thrift_proxy/v3:pkg_cc_proto",
],
Expand Down
27 changes: 23 additions & 4 deletions source/extensions/filters/network/thrift_proxy/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "source/extensions/filters/network/thrift_proxy/decoder.h"
#include "source/extensions/filters/network/thrift_proxy/filters/filter_config.h"
#include "source/extensions/filters/network/thrift_proxy/framed_transport_impl.h"
#include "source/extensions/filters/network/thrift_proxy/router/rds_impl.h"
#include "source/extensions/filters/network/thrift_proxy/stats.h"
#include "source/extensions/filters/network/thrift_proxy/unframed_transport_impl.h"

Expand Down Expand Up @@ -96,12 +97,22 @@ ProtocolType ProtocolOptionsConfigImpl::protocol(ProtocolType downstream_protoco
return (protocol_ == ProtocolType::Auto) ? downstream_protocol : protocol_;
}

SINGLETON_MANAGER_REGISTRATION(thrift_route_config_provider_manager);

Network::FilterFactoryCb ThriftProxyFilterConfigFactory::createFilterFactoryFromProtoTyped(
const envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy& proto_config,
Server::Configuration::FactoryContext& context) {
std::shared_ptr<Config> filter_config(new ConfigImpl(proto_config, context));
std::shared_ptr<Router::RouteConfigProviderManager> route_config_provider_manager =
context.singletonManager().getTyped<Router::RouteConfigProviderManager>(
SINGLETON_MANAGER_REGISTERED_NAME(thrift_route_config_provider_manager), [&context] {
return std::make_shared<Router::RouteConfigProviderManagerImpl>(context.admin());
});

std::shared_ptr<Config> filter_config(
new ConfigImpl(proto_config, context, *route_config_provider_manager));

return [filter_config, &context](Network::FilterManager& filter_manager) -> void {
return [route_config_provider_manager, filter_config,
&context](Network::FilterManager& filter_manager) -> void {
filter_manager.addReadFilter(std::make_shared<ConnectionManager>(
*filter_config, context.api().randomGenerator(), context.dispatcher().timeSource()));
};
Expand All @@ -115,11 +126,11 @@ REGISTER_FACTORY(ThriftProxyFilterConfigFactory,

ConfigImpl::ConfigImpl(
const envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy& config,
Server::Configuration::FactoryContext& context)
Server::Configuration::FactoryContext& context,
Router::RouteConfigProviderManager& route_config_provider_manager)
: context_(context), stats_prefix_(fmt::format("thrift.{}.", config.stat_prefix())),
stats_(ThriftFilterStats::generateStats(stats_prefix_, context_.scope())),
transport_(lookupTransport(config.transport())), proto_(lookupProtocol(config.protocol())),
route_matcher_(new Router::RouteMatcher(config.route_config())),
payload_passthrough_(config.payload_passthrough()),
max_requests_per_connection_(config.max_requests_per_connection().value()) {

Expand All @@ -134,6 +145,14 @@ ConfigImpl::ConfigImpl(
processFilter(filter);
}
}

if (config.has_rds()) {
route_config_provider_ = route_config_provider_manager.createRdsRouteConfigProvider(
config.rds(), context_.getServerFactoryContext(), stats_prefix_, context_.initManager());
} else {
route_config_provider_ = route_config_provider_manager.createStaticRouteConfigProvider(
config.route_config(), context_.getServerFactoryContext());
}
}

void ConfigImpl::createFilterChain(ThriftFilters::FilterChainFactoryCallbacks& callbacks) {
Expand Down
9 changes: 6 additions & 3 deletions source/extensions/filters/network/thrift_proxy/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "source/extensions/filters/network/thrift_proxy/conn_manager.h"
#include "source/extensions/filters/network/thrift_proxy/filters/filter.h"
#include "source/extensions/filters/network/thrift_proxy/protocol_options_config.h"
#include "source/extensions/filters/network/thrift_proxy/router/rds.h"
#include "source/extensions/filters/network/thrift_proxy/router/route_config_provider_manager.h"
#include "source/extensions/filters/network/thrift_proxy/router/router_impl.h"
#include "source/extensions/filters/network/well_known_names.h"

Expand Down Expand Up @@ -65,15 +67,16 @@ class ConfigImpl : public Config,
Logger::Loggable<Logger::Id::config> {
public:
ConfigImpl(const envoy::extensions::filters::network::thrift_proxy::v3::ThriftProxy& config,
Server::Configuration::FactoryContext& context);
Server::Configuration::FactoryContext& context,
Router::RouteConfigProviderManager& route_config_provider_manager);

// ThriftFilters::FilterChainFactory
void createFilterChain(ThriftFilters::FilterChainFactoryCallbacks& callbacks) override;

// Router::Config
Router::RouteConstSharedPtr route(const MessageMetadata& metadata,
uint64_t random_value) const override {
return route_matcher_->route(metadata, random_value);
return route_config_provider_->config()->route(metadata, random_value);
}

// Config
Expand All @@ -94,7 +97,7 @@ class ConfigImpl : public Config,
ThriftFilterStats stats_;
const TransportType transport_;
const ProtocolType proto_;
std::unique_ptr<Router::RouteMatcher> route_matcher_;
Router::RouteConfigProviderSharedPtr route_config_provider_;

std::list<ThriftFilters::FilterFactoryCb> filter_factories_;
const bool payload_passthrough_;
Expand Down
41 changes: 41 additions & 0 deletions source/extensions/filters/network/thrift_proxy/router/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,44 @@ envoy_cc_library(
"@envoy_api//envoy/config/route/v3:pkg_cc_proto",
],
)

envoy_cc_library(
name = "rds_interface",
hdrs = ["rds.h"],
deps = [
":router_interface",
"@envoy_api//envoy/extensions/filters/network/thrift_proxy/v3:pkg_cc_proto",
],
)

envoy_cc_library(
name = "rds_lib",
srcs = [
"rds_impl.cc",
"route_config_update_receiver_impl.cc",
],
hdrs = [
"rds_impl.h",
"route_config_provider_manager.h",
"route_config_update_receiver.h",
"route_config_update_receiver_impl.h",
],
deps = [
":config",
":rds_interface",
"//envoy/common:time_interface",
"//envoy/config:subscription_interface",
"//envoy/local_info:local_info_interface",
"//source/common/config:api_version_lib",
"//source/common/config:subscription_base_interface",
"//source/common/config:utility_lib",
"//source/common/init:manager_lib",
"//source/common/init:target_lib",
"//source/common/protobuf:utility_lib",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@envoy_api//envoy/config/route/v3:pkg_cc_proto",
"@envoy_api//envoy/extensions/filters/network/thrift_proxy/v3:pkg_cc_proto",
"@envoy_api//envoy/service/discovery/v3:pkg_cc_proto",
],
)
21 changes: 21 additions & 0 deletions source/extensions/filters/network/thrift_proxy/router/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "envoy/extensions/filters/network/thrift_proxy/router/v3/router.pb.validate.h"

#include "source/extensions/filters/network/thrift_proxy/filters/factory_base.h"
#include "source/extensions/filters/network/thrift_proxy/router/router_impl.h"

namespace Envoy {
namespace Extensions {
Expand All @@ -23,6 +24,26 @@ class RouterFilterConfig
const std::string& stat_prefix, Server::Configuration::FactoryContext& context) override;
};

class ConfigImpl : public Config, Logger::Loggable<Logger::Id::config> {
public:
ConfigImpl(
const envoy::extensions::filters::network::thrift_proxy::v3::RouteConfiguration& config)
: route_matcher_(new RouteMatcher(config)) {}

// Config
RouteConstSharedPtr route(const MessageMetadata& metadata, uint64_t random_value) const override {
return route_matcher_->route(metadata, random_value);
}

private:
std::unique_ptr<RouteMatcher> route_matcher_;
};

class NullConfigImpl : public Config {
public:
RouteConstSharedPtr route(const MessageMetadata&, uint64_t) const override { return nullptr; }
};

} // namespace Router
} // namespace ThriftProxy
} // namespace NetworkFilters
Expand Down
Loading