From 7d6dff5f13ed591da6f1d57fb885d5a9287ba6c3 Mon Sep 17 00:00:00 2001 From: "data-plane-api(CircleCI)" Date: Mon, 20 Aug 2018 16:35:36 +0000 Subject: [PATCH] thrift: allow translation between downstream and upstream protocols (#4136) We use the new extension_protocol_options field on Cluster to allow clusters to be configured with a transport and/or protocol. Downstream requests are automatically translated to the upstream dialect and upstream responses are translated back to the downstream's dialect. Moves the TransportType and ProtocolType protobuf enums out of the ThriftProxy message to allow their re-use in ThriftProtocolOptions. *Risk Level*: low *Testing*: integration test *Docs Changes*: added thrift filter docs *Release Notes*: n/a Signed-off-by: Stephan Zuercher Mirrored from https://github.com/envoyproxy/envoy @ c91625ed829a4ec4123bab8b4e6b223f67d88e4a --- docs/BUILD | 1 + .../network/thrift_proxy/v2alpha1/route.proto | 3 +- .../thrift_proxy/v2alpha1/thrift_proxy.proto | 94 ++++++++++++------- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/docs/BUILD b/docs/BUILD index 448534f9..cf17b23b 100644 --- a/docs/BUILD +++ b/docs/BUILD @@ -50,6 +50,7 @@ proto_library( "//envoy/config/filter/network/rbac/v2:rbac", "//envoy/config/filter/network/redis_proxy/v2:redis_proxy", "//envoy/config/filter/network/tcp_proxy/v2:tcp_proxy", + "//envoy/config/filter/network/thrift_proxy/v2alpha1:thrift_proxy", "//envoy/config/grpc_credential/v2alpha:file_based_metadata", "//envoy/config/health_checker/redis/v2:redis", "//envoy/config/metrics/v2:metrics_service", diff --git a/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto b/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto index 7aab4257..fc75cfe5 100644 --- a/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto +++ b/envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto @@ -6,7 +6,8 @@ option go_package = "v2"; import "validate/validate.proto"; import "gogoproto/gogo.proto"; -// [#protodoc-title: Thrift route configuration] +// [#protodoc-title: Thrift Proxy Route Configuration] +// Thrift Proxy :ref:`configuration overview `. // [#comment:next free field: 3] message RouteConfiguration { diff --git a/envoy/config/filter/network/thrift_proxy/v2alpha1/thrift_proxy.proto b/envoy/config/filter/network/thrift_proxy/v2alpha1/thrift_proxy.proto index 97c905ea..845399db 100644 --- a/envoy/config/filter/network/thrift_proxy/v2alpha1/thrift_proxy.proto +++ b/envoy/config/filter/network/thrift_proxy/v2alpha1/thrift_proxy.proto @@ -8,53 +8,79 @@ import "envoy/config/filter/network/thrift_proxy/v2alpha1/route.proto"; import "validate/validate.proto"; import "gogoproto/gogo.proto"; -// [#protodoc-title: Extensions Thrift Proxy] -// Thrift Proxy filter configuration. +// [#protodoc-title: Thrift Proxy] +// Thrift Proxy :ref:`configuration overview `. + // [#comment:next free field: 5] message ThriftProxy { - enum TransportType { - option (gogoproto.goproto_enum_prefix) = false; + // Supplies the type of transport that the Thrift proxy should use. Defaults to + // :ref:`AUTO_TRANSPORT`. + TransportType transport = 2 [(validate.rules).enum.defined_only = true]; - // For every new connection, the Thrift proxy will determine which transport to use. - AUTO_TRANSPORT = 0; + // Supplies the type of protocol that the Thrift proxy should use. Defaults to + // :ref:`AUTO_PROTOCOL`. + ProtocolType protocol = 3 [(validate.rules).enum.defined_only = true]; - // The Thrift proxy will assume the client is using the Thrift framed transport. - FRAMED = 1; + // The human readable prefix to use when emitting statistics. + string stat_prefix = 1 [(validate.rules).string.min_bytes = 1]; - // The Thrift proxy will assume the client is using the Thrift unframed transport. - UNFRAMED = 2; + // The route table for the connection manager is static and is specified in this property. + RouteConfiguration route_config = 4; +} - // The Thrift proxy will assume the client is using the Thrift header transport. - HEADER = 3; - } +// Thrift transport types supported by Envoy. +enum TransportType { + option (gogoproto.goproto_enum_prefix) = false; - // Supplies the type of transport that the Thrift proxy should use. Defaults to `AUTO_TRANSPORT`. - TransportType transport = 2 [(validate.rules).enum.defined_only = true]; + // For downstream connections, the Thrift proxy will attempt to determine which transport to use. + // For upstream connections, the Thrift proxy will use same transport as the downstream + // connection. + AUTO_TRANSPORT = 0; - enum ProtocolType { - option (gogoproto.goproto_enum_prefix) = false; + // The Thrift proxy will use the Thrift framed transport. + FRAMED = 1; - // For every new connection, the Thrift proxy will determine which protocol to use. - // N.B. The older, non-strict binary protocol is not included in automatic protocol - // detection. - AUTO_PROTOCOL = 0; + // The Thrift proxy will use the Thrift unframed transport. + UNFRAMED = 2; - // The Thrift proxy will assume the client is using the Thrift binary protocol. - BINARY = 1; + // The Thrift proxy will assume the client is using the Thrift header transport. + HEADER = 3; +} - // The Thrift proxy will assume the client is using the Thrift non-strict binary protocol. - LAX_BINARY = 2; +// Thrift Protocol types supported by Envoy. +enum ProtocolType { + option (gogoproto.goproto_enum_prefix) = false; - // The Thrift proxy will assume the client is using the Thrift compact protocol. - COMPACT = 3; - } + // For downstream connections, the Thrift proxy will attempt to determine which protocol to use. + // Note that the older, non-strict (or lax) binary protocol is not included in automatic protocol + // detection. For upstream connections, the Thrift proxy will use the same protocol as the + // downstream connection. + AUTO_PROTOCOL = 0; - // Supplies the type of protocol that the Thrift proxy should use. Defaults to `AUTO_PROTOCOL`. - ProtocolType protocol = 3 [(validate.rules).enum.defined_only = true]; + // The Thrift proxy will use the Thrift binary protocol. + BINARY = 1; - // The human readable prefix to use when emitting statistics. - string stat_prefix = 1 [(validate.rules).string.min_bytes = 1]; + // The Thrift proxy will use Thrift non-strict binary protocol. + LAX_BINARY = 2; - // The route table for the connection manager is static and is specified in this property. - RouteConfiguration route_config = 4; + // The Thrift proxy will use the Thrift compact protocol. + COMPACT = 3; +} + +// ThriftProtocolOptions specifies Thrift upstream protocol options. This object is used in +// in :ref:`extension_protocol_options`, keyed +// by the name `envoy.filters.network.thrift_proxy`. +// [#comment:next free field: 3] +message ThriftProtocolOptions { + // Supplies the type of transport that the Thrift proxy should use for upstream connections. + // Selecting + // :ref:`AUTO_TRANSPORT`, + // which is the default, causes the proxy to use the same transport as the downstream connection. + TransportType transport = 1 [(validate.rules).enum.defined_only = true]; + + // Supplies the type of protocol that the Thrift proxy should use for upstream connections. + // Selecting + // :ref:`AUTO_PROTOCOL`, + // 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]; }