-
Notifications
You must be signed in to change notification settings - Fork 5.3k
thrift: adding xDS RDS support for thrift proxy. #17631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7448070
Adding xDS RDS support for thrift protocol.
eb5dc21
Fix generated_api_shadow
fcc2abf
Merge main
d1e2124
Fix missed file
4609c02
Fix conn_manager_test
f48daed
Fix router_ratelimit_test
0022eed
Fix clang_tidy
3235184
More type urls can identify the same RouteDiscoveryService endpoint
12aa485
Merge branch 'main' into add_thrift_rds
6506f20
Fix merge conflict resolution, add test
e9bb514
Dummy
b95bf8e
Merge branch 'main' into add_thrift_rds
fbf27dc
Template base classes for rds handling.
cd88857
Merge branch 'main' into add_thrift_rds_rework
aeb9476
Fix RouteConfigUpdateReceiverImpl::onVhdsUpdate
7811138
Fix clang-tidy errors
508f711
Fix clang-tidy errors, missing build dependencies
c28ff34
Merge branch 'main' into add_thrift_rds_rework
8ca0a4f
Debug strange lua filter coverage issue
639148d
Revert: Debug strange lua filter coverage issue
054460e
Separate service endpoint to Thrift rds
0695c52
Move service to thrift rds into api/envoy/services
15e1747
Kick CI
f6f111c
Simplifications
4414291
Merge branch 'main' into add_thrift_rds
b9ab26f
Add prefix to Thrift rds related proto names in the api.
44f9ea8
Fix missed file
4ae0e46
Kick CI
ab9e419
Kick CI
bbc830b
Change TRDS method names similar to other DS method names
cd7c2d7
Fix ut
8e9dbea
Merge branch 'main' into add_thrift_rds
7d93eb6
Eliminate templates from generic rds base classes.
22d91c7
Fix CI issues.
54090b2
Fix CI issues.
2e94bda
Fix CI issues.
d8b377f
Fix CI issues.
8209da5
Fix CI issues, clang-tidy.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. | ||
|
|
||
| load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| api_proto_package( | ||
| has_services = True, | ||
| deps = [ | ||
| "//envoy/annotations:pkg", | ||
| "//envoy/service/discovery/v3:pkg", | ||
| "@com_github_cncf_udpa//udpa/annotations:pkg", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package envoy.service.thrift.v3; | ||
|
|
||
| import "envoy/service/discovery/v3/discovery.proto"; | ||
|
|
||
| import "google/api/annotations.proto"; | ||
|
|
||
| import "envoy/annotations/resource.proto"; | ||
| import "udpa/annotations/status.proto"; | ||
| import "udpa/annotations/versioning.proto"; | ||
|
|
||
| option java_package = "io.envoyproxy.envoy.service.thrift.v3"; | ||
| option java_outer_classname = "TrdsProto"; | ||
| option java_multiple_files = true; | ||
| option java_generic_services = true; | ||
| option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
|
||
| // [#protodoc-title: TRDS] | ||
|
|
||
| // The resource_names field in DiscoveryRequest specifies a route configuration. | ||
| // This allows an Envoy configuration with multiple Thrift listeners (and | ||
| // associated Thrift proxy filters) to use different route | ||
| // configurations. Each listener will bind its Thrift proxy filter to | ||
| // a route table via this identifier. | ||
| service ThriftRouteDiscoveryService { | ||
| option (envoy.annotations.resource).type = | ||
| "envoy.extensions.filters.network.thrift_proxy.v3.RouteConfiguration"; | ||
|
|
||
| rpc StreamThriftRoutes(stream discovery.v3.DiscoveryRequest) | ||
| returns (stream discovery.v3.DiscoveryResponse) { | ||
| } | ||
|
|
||
| rpc DeltaThriftRoutes(stream discovery.v3.DeltaDiscoveryRequest) | ||
| returns (stream discovery.v3.DeltaDiscoveryResponse) { | ||
| } | ||
|
|
||
| rpc FetchThriftRoutes(discovery.v3.DiscoveryRequest) returns (discovery.v3.DiscoveryResponse) { | ||
| option (google.api.http).post = "/v3/discovery:thrift_routes"; | ||
| option (google.api.http).body = "*"; | ||
| } | ||
| } | ||
|
|
||
| // [#not-implemented-hide:] Not configuration. Workaround c++ protobuf issue with importing | ||
| // services: https://github.com/google/protobuf/issues/4221 and protoxform to upgrade the file. | ||
| message TrdsDummy { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| load( | ||
| "//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_library", | ||
| "envoy_package", | ||
| ) | ||
|
|
||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| envoy_package() | ||
|
|
||
| envoy_cc_library( | ||
| name = "rds_interface", | ||
| hdrs = [ | ||
| "config.h", | ||
| "config_traits.h", | ||
| "route_config_provider.h", | ||
| "route_config_update_receiver.h", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| namespace Envoy { | ||
| namespace Rds { | ||
|
|
||
| /** | ||
| * Base class for router configuration classes used with Rds. | ||
| */ | ||
| class Config { | ||
| public: | ||
| virtual ~Config() = default; | ||
| }; | ||
|
|
||
| using ConfigConstSharedPtr = std::shared_ptr<const Config>; | ||
|
|
||
| } // namespace Rds | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "envoy/common/pure.h" | ||
| #include "envoy/rds/config.h" | ||
|
|
||
| #include "source/common/protobuf/protobuf.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Rds { | ||
|
|
||
| /** | ||
| * Traits of the protocol specific route configuration and proto. | ||
| * The generic rds classes will call the methods of this interface | ||
| * to get information which are not visible for them directly. | ||
| */ | ||
| class ConfigTraits { | ||
| public: | ||
| virtual ~ConfigTraits() = default; | ||
|
|
||
| /** | ||
| * Give the full name of the route configuration proto description. | ||
| * For example 'envoy.config.route.v3.RouteConfiguration' | ||
| */ | ||
| virtual std::string resourceType() const PURE; | ||
|
|
||
| /** | ||
| * Create a dummy config object without actual route configuration. | ||
| * This object will be used before the first valid route configuration is fetched. | ||
| */ | ||
| virtual ConfigConstSharedPtr createConfig() const PURE; | ||
|
|
||
| /** | ||
| * Create an empty route configuration proto object. | ||
| */ | ||
| virtual ProtobufTypes::MessagePtr createProto() const PURE; | ||
|
|
||
| /** | ||
| * Runtime check if the provided proto message object is really a route configuration instance. | ||
| * Throw an std::bad_cast exception if not. | ||
| * Every other method below this assumes the proto message is already | ||
| * validated and and doesn't do any further runtime check. | ||
| */ | ||
| virtual const Protobuf::Message& validateResourceType(const Protobuf::Message& rc) const PURE; | ||
|
|
||
| /** | ||
| * Check if a valid config object can be made based on the provided route configuration proto. | ||
| * Throw an exception if not. | ||
| */ | ||
| virtual const Protobuf::Message& validateConfig(const Protobuf::Message& rc) const PURE; | ||
|
|
||
| /** | ||
| * Gives back the value of the name field Check if a valid config object can be made | ||
| * based on the provided route configuration proto. | ||
| * The object behind the returned reference has to have the same lifetime like the proto. | ||
| */ | ||
| virtual const std::string& resourceName(const Protobuf::Message& rc) const PURE; | ||
|
|
||
| /** | ||
| * Create a config object based on a route configuration. | ||
| */ | ||
| virtual ConfigConstSharedPtr createConfig(const Protobuf::Message& rc) const PURE; | ||
|
|
||
| /** | ||
| * Clones the route configuration proto. | ||
| */ | ||
| virtual ProtobufTypes::MessagePtr cloneProto(const Protobuf::Message& rc) const PURE; | ||
| }; | ||
|
|
||
| } // namespace Rds | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "envoy/common/time.h" | ||
| #include "envoy/rds/config.h" | ||
|
|
||
| #include "source/common/protobuf/protobuf.h" | ||
|
|
||
| #include "absl/types/optional.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Rds { | ||
|
|
||
| /** | ||
| * A provider for constant route configurations. | ||
| */ | ||
| class RouteConfigProvider { | ||
| public: | ||
| struct ConfigInfo { | ||
| // A reference to the currently loaded route configuration. Do not hold this reference beyond | ||
| // the caller of configInfo()'s scope. | ||
| const Protobuf::Message& config_; | ||
|
|
||
| const std::string& name_; | ||
|
|
||
| // The discovery version that supplied this route. This will be set to "" in the case of | ||
| // static clusters. | ||
| std::string version_; | ||
tkovacs-2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| virtual ~RouteConfigProvider() = default; | ||
|
|
||
| /** | ||
| * @return ConfigConstSharedPtr a route configuration for use during a single request. The | ||
| * returned config may be different on a subsequent call, so a new config should be acquired for | ||
| * each request flow. | ||
| */ | ||
| virtual ConfigConstSharedPtr config() PURE; | ||
|
|
||
| /** | ||
| * @return the configuration information for the currently loaded route configuration. Note that | ||
| * if the provider has not yet performed an initial configuration load, no information will be | ||
| * returned. | ||
| */ | ||
| virtual absl::optional<ConfigInfo> configInfo() const PURE; | ||
|
|
||
| /** | ||
| * @return the last time this RouteConfigProvider was updated. Used for config dumps. | ||
| */ | ||
| virtual SystemTime lastUpdated() const PURE; | ||
|
|
||
| /** | ||
| * Callback used to notify RouteConfigProvider about configuration changes. | ||
| */ | ||
| virtual void onConfigUpdate() PURE; | ||
| }; | ||
|
|
||
| using RouteConfigProviderPtr = std::unique_ptr<RouteConfigProvider>; | ||
| using RouteConfigProviderSharedPtr = std::shared_ptr<RouteConfigProvider>; | ||
|
|
||
| } // namespace Rds | ||
| } // namespace Envoy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "envoy/common/pure.h" | ||
| #include "envoy/common/time.h" | ||
| #include "envoy/rds/config_traits.h" | ||
| #include "envoy/rds/route_config_provider.h" | ||
|
|
||
| #include "absl/types/optional.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Rds { | ||
|
|
||
| /** | ||
| * A primitive that keeps track of updates to a RouteConfiguration. | ||
| */ | ||
| class RouteConfigUpdateReceiver { | ||
| public: | ||
| virtual ~RouteConfigUpdateReceiver() = default; | ||
|
|
||
| /** | ||
| * Called on updates via RDS. | ||
| * @param rc supplies the RouteConfiguration. | ||
| * @param version_info supplies RouteConfiguration version. | ||
| * @return bool whether RouteConfiguration has been updated. | ||
| */ | ||
| virtual bool onRdsUpdate(const Protobuf::Message& rc, const std::string& version_info) PURE; | ||
|
|
||
| /** | ||
| * @return std::string& the name of RouteConfiguration. | ||
| */ | ||
| virtual const std::string& routeConfigName() const PURE; | ||
|
|
||
| /** | ||
| * @return std::string& the version of RouteConfiguration. | ||
| */ | ||
| virtual const std::string& configVersion() const PURE; | ||
|
|
||
| /** | ||
| * @return uint64_t the hash value of RouteConfiguration. | ||
| */ | ||
| virtual uint64_t configHash() const PURE; | ||
|
|
||
| /** | ||
| * @return absl::optional<RouteConfigProvider::ConfigInfo> containing an instance of | ||
| * RouteConfigProvider::ConfigInfo if RouteConfiguration has been updated at least once. Otherwise | ||
| * returns an empty absl::optional<RouteConfigProvider::ConfigInfo>. | ||
| */ | ||
| virtual absl::optional<RouteConfigProvider::ConfigInfo> configInfo() const PURE; | ||
|
|
||
| /** | ||
| * @return envoy::config::route::v3::RouteConfiguration& current RouteConfiguration. | ||
| */ | ||
| virtual const Protobuf::Message& protobufConfiguration() PURE; | ||
|
|
||
| /** | ||
| * @return ConfigConstSharedPtr a parsed and validated copy of current RouteConfiguration. | ||
| * @see protobufConfiguration() | ||
| */ | ||
| virtual ConfigConstSharedPtr parsedConfiguration() const PURE; | ||
|
|
||
| /** | ||
| * @return SystemTime the time of the last update. | ||
| */ | ||
| virtual SystemTime lastUpdated() const PURE; | ||
|
|
||
| virtual const ConfigTraits& configTraits() const PURE; | ||
| }; | ||
|
|
||
| using RouteConfigUpdatePtr = std::unique_ptr<RouteConfigUpdateReceiver>; | ||
|
|
||
| } // namespace Rds | ||
| } // namespace Envoy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.