From ece7d99193429dffaa1b5ea12ee3cd1588df7c8b Mon Sep 17 00:00:00 2001 From: "data-plane-api(CircleCI)" Date: Fri, 7 Sep 2018 19:15:35 +0000 Subject: [PATCH] [thrift_proxy] Add and implement weighted clusters to thrift.RouteAction (#4315) Adding the ability to add weighted clusters to the thrift router's RouteAction proto. This works much like the http one and borrows a great deal of code from it. Since the thrift_proxy Route and RouteEntry interfaces are much more bare bones, was able to implement the WeightedClusterEntry class. Risk Level: Low Testing: Tests, new and old, pass Doc Changes: inline Release Notes: n/a Signed-off-by: Brian Ramos Mirrored from https://github.com/envoyproxy/envoy @ a50ac3747623a7fa74a5dbd33eacf0808dbf4d0c --- .../network/thrift_proxy/v2alpha1/BUILD | 1 + .../network/thrift_proxy/v2alpha1/route.proto | 38 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/envoy/config/filter/network/thrift_proxy/v2alpha1/BUILD b/envoy/config/filter/network/thrift_proxy/v2alpha1/BUILD index d9ec9e34..24408194 100644 --- a/envoy/config/filter/network/thrift_proxy/v2alpha1/BUILD +++ b/envoy/config/filter/network/thrift_proxy/v2alpha1/BUILD @@ -9,6 +9,7 @@ api_proto_library_internal( "thrift_proxy.proto", ], deps = [ + "//envoy/api/v2/core:base", "//envoy/api/v2/route", ], ) diff --git a/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto b/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto index 7fb9ce99..7e5255f4 100644 --- a/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto +++ b/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto @@ -3,7 +3,11 @@ syntax = "proto3"; package envoy.config.filter.network.thrift_proxy.v2alpha1; option go_package = "v2"; +import "envoy/api/v2/core/base.proto"; import "envoy/api/v2/route/route.proto"; + +import "google/protobuf/wrappers.proto"; + import "validate/validate.proto"; import "gogoproto/gogo.proto"; @@ -66,8 +70,36 @@ message RouteMatch { repeated envoy.api.v2.route.HeaderMatcher headers = 4; } -// [#comment:next free field: 2] +// [#comment:next free field: 3] message RouteAction { - // Indicates the upstream cluster to which the request should be routed. - string cluster = 1 [(validate.rules).string.min_bytes = 1]; + oneof cluster_specifier { + option (validate.required) = true; + + // Indicates a single upstream cluster to which the request should be routed + // to. + string cluster = 1 [(validate.rules).string.min_bytes = 1]; + + // Multiple upstream clusters can be specified for a given route. The + // request is routed to one of the upstream clusters based on weights + // assigned to each cluster. + WeightedCluster weighted_clusters = 2; + } +} + +// Allows for specification of multiple upstream clusters along with weights that indicate the +// percentage of traffic to be forwarded to each cluster. The router selects an upstream cluster +// based on these weights. +message WeightedCluster { + message ClusterWeight { + // Name of the upstream cluster. + string name = 1 [(validate.rules).string.min_bytes = 1]; + + // When a request matches the route, the choice of an upstream cluster is determined by its + // weight. The sum of weights across all entries in the clusters array determines the total + // weight. + google.protobuf.UInt32Value weight = 2 [(validate.rules).uint32.gte = 1]; + } + + // Specifies one or more upstream clusters associated with the route. + repeated ClusterWeight clusters = 1 [(validate.rules).repeated .min_items = 1]; }