From f9fd4fb1f633870b1a7025a3b1537cc5c3d03d13 Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Mon, 9 Aug 2021 15:05:59 +0000 Subject: [PATCH] thrift proxy: add request shadowing support (#17544) This is the last PR in the series dedicated to adding mirroring support. It adds: * the ShadowWriter which is used by the Router filter to mirror requests * a ShadowRouter which is a RequestOwner that reuses the existing UpstreamRequest There's still room for more code sharing and better interfaces, but that can happen in future iterations. Signed-off-by: Raul Gutierrez Segales Mirrored from https://github.com/envoyproxy/envoy @ 7a93615ec1077bbb3b20ada1fc8a440751da1c9f --- .../network/thrift_proxy/v3/route.proto | 27 ++++++++++++++++- .../network/thrift_proxy/v4alpha/route.proto | 30 ++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/envoy/extensions/filters/network/thrift_proxy/v3/route.proto b/envoy/extensions/filters/network/thrift_proxy/v3/route.proto index cf4c06ae..b79c9bc9 100644 --- a/envoy/extensions/filters/network/thrift_proxy/v3/route.proto +++ b/envoy/extensions/filters/network/thrift_proxy/v3/route.proto @@ -81,11 +81,33 @@ message RouteMatch { repeated config.route.v3.HeaderMatcher headers = 4; } -// [#next-free-field: 7] +// [#next-free-field: 8] message RouteAction { option (udpa.annotations.versioning).previous_message_type = "envoy.config.filter.network.thrift_proxy.v2alpha1.RouteAction"; + // The router is capable of shadowing traffic from one cluster to another. The current + // implementation is "fire and forget," meaning Envoy will not wait for the shadow cluster to + // respond before returning the response from the primary cluster. All normal statistics are + // collected for the shadow cluster making this feature useful for testing. + // + // .. note:: + // + // Shadowing will not be triggered if the primary cluster does not exist. + message RequestMirrorPolicy { + // Specifies the cluster that requests will be mirrored to. The cluster must + // exist in the cluster manager configuration when the route configuration is loaded. + // If it disappears at runtime, the shadow request will silently be ignored. + string cluster = 1 [(validate.rules).string = {min_len: 1}]; + + // If not specified, all requests to the target cluster will be mirrored. + // + // For some fraction N/D, a random number in the range [0,D) is selected. If the + // number is <= the value of the numerator N, or if the key is not present, the default + // value, the request will be mirrored. + config.core.v3.RuntimeFractionalPercent runtime_fraction = 2; + } + oneof cluster_specifier { option (validate.required) = true; @@ -123,6 +145,9 @@ message RouteAction { // Strip the service prefix from the method name, if there's a prefix. For // example, the method call Service:method would end up being just method. bool strip_service_name = 5; + + // Indicates that the route has request mirroring policies. + repeated RequestMirrorPolicy request_mirror_policies = 7; } // Allows for specification of multiple upstream clusters along with weights that indicate the diff --git a/envoy/extensions/filters/network/thrift_proxy/v4alpha/route.proto b/envoy/extensions/filters/network/thrift_proxy/v4alpha/route.proto index e638e9b8..48caaadf 100644 --- a/envoy/extensions/filters/network/thrift_proxy/v4alpha/route.proto +++ b/envoy/extensions/filters/network/thrift_proxy/v4alpha/route.proto @@ -81,11 +81,36 @@ message RouteMatch { repeated config.route.v4alpha.HeaderMatcher headers = 4; } -// [#next-free-field: 7] +// [#next-free-field: 8] message RouteAction { option (udpa.annotations.versioning).previous_message_type = "envoy.extensions.filters.network.thrift_proxy.v3.RouteAction"; + // The router is capable of shadowing traffic from one cluster to another. The current + // implementation is "fire and forget," meaning Envoy will not wait for the shadow cluster to + // respond before returning the response from the primary cluster. All normal statistics are + // collected for the shadow cluster making this feature useful for testing. + // + // .. note:: + // + // Shadowing will not be triggered if the primary cluster does not exist. + message RequestMirrorPolicy { + option (udpa.annotations.versioning).previous_message_type = + "envoy.extensions.filters.network.thrift_proxy.v3.RouteAction.RequestMirrorPolicy"; + + // Specifies the cluster that requests will be mirrored to. The cluster must + // exist in the cluster manager configuration when the route configuration is loaded. + // If it disappears at runtime, the shadow request will silently be ignored. + string cluster = 1 [(validate.rules).string = {min_len: 1}]; + + // If not specified, all requests to the target cluster will be mirrored. + // + // For some fraction N/D, a random number in the range [0,D) is selected. If the + // number is <= the value of the numerator N, or if the key is not present, the default + // value, the request will be mirrored. + config.core.v4alpha.RuntimeFractionalPercent runtime_fraction = 2; + } + oneof cluster_specifier { option (validate.required) = true; @@ -123,6 +148,9 @@ message RouteAction { // Strip the service prefix from the method name, if there's a prefix. For // example, the method call Service:method would end up being just method. bool strip_service_name = 5; + + // Indicates that the route has request mirroring policies. + repeated RequestMirrorPolicy request_mirror_policies = 7; } // Allows for specification of multiple upstream clusters along with weights that indicate the