Skip to content
Closed
Show file tree
Hide file tree
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.
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 @@ -247,6 +247,7 @@ proto_library(
"//envoy/service/secret/v3:pkg",
"//envoy/service/status/v3:pkg",
"//envoy/service/tap/v3:pkg",
"//envoy/service/thrift/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,16 @@ enum ProtocolType {
TWITTER = 4;
}

// [#next-free-field: 8]
message Trds {
// Configuration source specifier.
config.core.v3.ConfigSource config_source = 1 [(validate.rules).message = {required: true}];

// The name of the route configuration. This allows to use different route
// configurations. Tells which route configuration should be fetched from the configuration source.
string route_config_name = 2;
}

// [#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 +86,9 @@ 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;
// If trds is also defined this field is ignored.
RouteConfiguration route_config = 4
[(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 +105,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 trds defined, trds has priority.
Trds trds = 8 [(udpa.annotations.field_migrate).oneof_promotion = "route_specifier"];
}

// ThriftFilter configures a Thrift filter.
Expand Down
14 changes: 14 additions & 0 deletions api/envoy/service/thrift/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/v3/trds.proto
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 {
}
1 change: 1 addition & 0 deletions api/versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ proto_library(
"//envoy/service/secret/v3:pkg",
"//envoy/service/status/v3:pkg",
"//envoy/service/tap/v3:pkg",
"//envoy/service/thrift/v3:pkg",
"//envoy/service/trace/v3:pkg",
"//envoy/type/http/v3:pkg",
"//envoy/type/matcher/v3:pkg",
Expand Down
19 changes: 19 additions & 0 deletions envoy/rds/BUILD
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",
],
)
19 changes: 19 additions & 0 deletions envoy/rds/config.h
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
72 changes: 72 additions & 0 deletions envoy/rds/config_traits.h
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
63 changes: 63 additions & 0 deletions envoy/rds/route_config_provider.h
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_;
};

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
74 changes: 74 additions & 0 deletions envoy/rds/route_config_update_receiver.h
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
2 changes: 2 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/rds:rds_interface",
"@envoy_api//envoy/config/route/v3:pkg_cc_proto",
],
)
Expand Down Expand Up @@ -70,6 +71,7 @@ envoy_cc_library(
"//envoy/http:conn_pool_interface",
"//envoy/http:hash_policy_interface",
"//envoy/http:header_map_interface",
"//envoy/rds:rds_interface",
"//envoy/tcp:conn_pool_interface",
"//envoy/tracing:http_tracer_interface",
"//envoy/upstream:resource_manager_interface",
Expand Down
Loading