From 77872e2bb4862ae36a4175e6e1125d908362140c Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Fri, 27 Aug 2021 03:42:10 +0000 Subject: [PATCH] [API] Allow routing to the cluster specified in the request_header for weighted cluster case. (#17673) - Add cluster header to weighted cluster proto. This enables the ability of routing to the cluster specified in the request_header for weighted cluster (i.e. multiple upstreams) case. name and cluster_header will be oneof cluster_specifiter field in the next release. Currently, they can only be regular fields due to compatibility issue. - Add the validation logic (PGV annotation + runtime check) - Add 3 unit tests for invalid weighted cluster configs. Note: I have implemented the core implementation and tested it with end-to-end integration test/example locally. Those changes will be in a separate PR once this API change is approved. Risk Level: Low Testing: CI, added an integration test for implementation of this API locally Signed-off-by: Tianyu Xia Mirrored from https://github.com/envoyproxy/envoy @ ef70185f3ac241d09eabfe15c65b0d631134f74f --- envoy/config/route/v3/route_components.proto | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/envoy/config/route/v3/route_components.proto b/envoy/config/route/v3/route_components.proto index daf1f8c2..e6be0c43 100644 --- a/envoy/config/route/v3/route_components.proto +++ b/envoy/config/route/v3/route_components.proto @@ -312,7 +312,7 @@ message Route { message WeightedCluster { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.route.WeightedCluster"; - // [#next-free-field: 12] + // [#next-free-field: 13] message ClusterWeight { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.route.WeightedCluster.ClusterWeight"; @@ -321,9 +321,31 @@ message WeightedCluster { reserved "per_filter_config"; + // Only one of *name* and *cluster_header* may be specified. + // [#next-major-version: Need to add back the validation rule: (validate.rules).string = {min_len: 1}] // Name of the upstream cluster. The cluster must exist in the // :ref:`cluster manager configuration `. - string name = 1 [(validate.rules).string = {min_len: 1}]; + string name = 1 [(udpa.annotations.field_migrate).oneof_promotion = "cluster_specifier"]; + + // Only one of *name* and *cluster_header* may be specified. + // [#next-major-version: Need to add back the validation rule: (validate.rules).string = {min_len: 1 }] + // Envoy will determine the cluster to route to by reading the value of the + // HTTP header named by cluster_header from the request headers. If the + // header is not found or the referenced cluster does not exist, Envoy will + // return a 404 response. + // + // .. attention:: + // + // Internally, Envoy always uses the HTTP/2 *:authority* header to represent the HTTP/1 + // *Host* header. Thus, if attempting to match on *Host*, match on *:authority* instead. + // + // .. note:: + // + // If the header appears multiple times only the first value is used. + string cluster_header = 12 [ + (validate.rules).string = {well_known_regex: HTTP_HEADER_NAME strict: false}, + (udpa.annotations.field_migrate).oneof_promotion = "cluster_specifier" + ]; // An integer between 0 and :ref:`total_weight // `. When a request matches the route,