Skip to content
Closed
Show file tree
Hide file tree
Changes from 24 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
1 change: 1 addition & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ proto_library(
"//envoy/service/secret/v3:pkg",
"//envoy/service/status/v3:pkg",
"//envoy/service/tap/v3:pkg",
"//envoy/service/thrift_route/v3:pkg",
"//envoy/service/trace/v3:pkg",
"//envoy/type/http/v3:pkg",
"//envoy/type/matcher/v3:pkg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ 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";
import "google/protobuf/wrappers.proto";

import "udpa/annotations/migrate.proto";
import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";
Expand Down Expand Up @@ -58,7 +60,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 All @@ -75,7 +77,8 @@ message ThriftProxy {
string stat_prefix = 1 [(validate.rules).string = {min_len: 1}];

// The route table for the connection manager is static and is specified in this property.
RouteConfiguration route_config = 4;
RouteConfiguration route_config = 4
Comment thread
tkovacs-2 marked this conversation as resolved.
[(udpa.annotations.field_migrate).oneof_promotion = "route_specifier"];

// A list of individual Thrift filters that make up the filter chain for requests made to the
// Thrift proxy. Order matters as the filters are processed sequentially. For backwards
Expand All @@ -92,6 +95,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 [(udpa.annotations.field_migrate).oneof_promotion = "route_specifier"];
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
}

// ThriftFilter configures a Thrift filter.
Expand Down Expand Up @@ -138,3 +144,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;
}
14 changes: 14 additions & 0 deletions api/envoy/service/thrift_route/v3/BUILD
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",
],
)
47 changes: 47 additions & 0 deletions api/envoy/service/thrift_route/v3/rds.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";

package envoy.service.thrift_route.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_route.v3";
option java_outer_classname = "RdsProto";
option java_multiple_files = true;
option java_generic_services = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: THRIFT_RDS]

// 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 RouteDiscoveryService {
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
option (envoy.annotations.resource).type =
"envoy.extensions.filters.network.thrift_proxy.v3.RouteConfiguration";

rpc StreamRoutes(stream discovery.v3.DiscoveryRequest)
returns (stream discovery.v3.DiscoveryResponse) {
}

rpc DeltaRoutes(stream discovery.v3.DeltaDiscoveryRequest)
returns (stream discovery.v3.DeltaDiscoveryResponse) {
}

rpc FetchRoutes(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 RdsDummy {
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
}
1 change: 1 addition & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ proto_library(
"//envoy/service/secret/v3:pkg",
"//envoy/service/status/v3:pkg",
"//envoy/service/tap/v3:pkg",
"//envoy/service/thrift_route/v3:pkg",
"//envoy/service/trace/v3:pkg",
"//envoy/type/http/v3:pkg",
"//envoy/type/matcher/v3:pkg",
Expand Down
9 changes: 9 additions & 0 deletions envoy/router/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ envoy_cc_library(
deps = [
":router_interface",
"//envoy/http:filter_interface",
"//envoy/router:rds_template_interface",
"@envoy_api//envoy/config/route/v3:pkg_cc_proto",
],
)
Expand Down Expand Up @@ -129,3 +130,11 @@ envoy_cc_library(
"//source/common/common:minimal_logger_lib",
],
)

envoy_cc_library(
name = "rds_template_interface",
hdrs = [
"rds/route_config_provider.h",
"rds/route_config_update_receiver.h",
],
)
49 changes: 3 additions & 46 deletions envoy/router/rds.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,15 @@

#include "envoy/config/route/v3/route.pb.h"
#include "envoy/http/filter.h"
#include "envoy/router/rds/route_config_provider.h"
#include "envoy/router/router.h"

namespace Envoy {
namespace Router {

/**
* A provider for constant route configurations.
*/
class RouteConfigProvider {
class RouteConfigProvider
: public Rds::RouteConfigProvider<envoy::config::route::v3::RouteConfiguration, Config> {
public:
struct ConfigInfo {
// A reference to the currently loaded route configuration. Do not hold this reference beyond
// the caller of configInfo()'s scope.
const envoy::config::route::v3::RouteConfiguration& config_;

// The discovery version that supplied this route. This will be set to "" in the case of
// static clusters.
std::string version_;
};

virtual ~RouteConfigProvider() = default;

/**
* @return Router::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 Router::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;

/**
* Validate if the route configuration can be applied to the context of the route config provider.
*/
virtual void
validateConfig(const envoy::config::route::v3::RouteConfiguration& config) const PURE;

/**
* Callback used to request an update to the route configuration from the management server.
* @param for_domain supplies the domain name that virtual hosts must match on
Expand Down
68 changes: 68 additions & 0 deletions envoy/router/rds/route_config_provider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#pragma once

#include <memory>

#include "envoy/common/time.h"

#include "absl/types/optional.h"

namespace Envoy {
namespace Router {
namespace Rds {

/**
* A provider for constant route configurations.
*/
template <class RouteConfiguration, class Config> class RouteConfigProvider {
Comment thread
tkovacs-2 marked this conversation as resolved.
Outdated
public:
struct ConfigInfo {
// A reference to the currently loaded route configuration. Do not hold this reference beyond
// the caller of configInfo()'s scope.
const RouteConfiguration& config_;

// The discovery version that supplied this route. This will be set to "" in the case of
// static clusters.
std::string version_;
};

virtual ~RouteConfigProvider() = default;

/**
* @return Router::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 std::shared_ptr<const Config> 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;

/**
* Validate if the route configuration can be applied to the context of the route config provider.
*/
virtual void validateConfig(const RouteConfiguration& config) const PURE;
};

template <class RouteConfiguration, class Config>
using RouteConfigProviderPtr = std::unique_ptr<RouteConfigProvider<RouteConfiguration, Config>>;
template <class RouteConfiguration, class Config>
using RouteConfigProviderSharedPtr =
std::shared_ptr<RouteConfigProvider<RouteConfiguration, Config>>;

} // namespace Rds
} // namespace Router
} // namespace Envoy
75 changes: 75 additions & 0 deletions envoy/router/rds/route_config_update_receiver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once

#include <memory>

#include "envoy/common/pure.h"
#include "envoy/common/time.h"
#include "envoy/router/rds/route_config_provider.h"

#include "absl/types/optional.h"

namespace Envoy {
namespace Router {
namespace Rds {

/**
* A primitive that keeps track of updates to a RouteConfiguration.
*/
template <class RouteConfiguration, class Config> 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 RouteConfiguration& 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<typename RouteConfigProvider<RouteConfiguration, Config>::ConfigInfo>
configInfo() const PURE;

/**
* @return envoy::config::route::v3::RouteConfiguration& current RouteConfiguration.
*/
virtual const RouteConfiguration& protobufConfiguration() PURE;

/**
* @return Router::ConfigConstSharedPtr a parsed and validated copy of current RouteConfiguration.
* @see protobufConfiguration()
*/
virtual std::shared_ptr<const Config> parsedConfiguration() const PURE;

/**
* @return SystemTime the time of the last update.
*/
virtual SystemTime lastUpdated() const PURE;
};

template <class RouteConfiguration, class Config>
using RouteConfigUpdatePtr = std::unique_ptr<RouteConfigUpdateReceiver<RouteConfiguration, Config>>;

} // namespace Rds
} // namespace Router
} // namespace Envoy
Loading