From 6839b73b0846db239b190b17a49551c7c9c6cc4e Mon Sep 17 00:00:00 2001 From: vishalpowar Date: Wed, 18 Jul 2018 15:38:33 -0700 Subject: [PATCH] Add support for drop category policy and reporting This PR contains changes to implement feature requested in issue #3823 - Adding DropOverload in eds policy which can be used to specify drop_percentage per category. - Adding DroppedRequests in load_report which can report deliberately dropped requests for each category. Signed-off-by: vishalpowar --- api/envoy/api/v2/BUILD | 2 ++ api/envoy/api/v2/eds.proto | 36 +++++++++++++++++---- api/envoy/api/v2/endpoint/load_report.proto | 10 ++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/api/envoy/api/v2/BUILD b/api/envoy/api/v2/BUILD index 09bdf6ddbf2ae..261d140819985 100644 --- a/api/envoy/api/v2/BUILD +++ b/api/envoy/api/v2/BUILD @@ -40,6 +40,7 @@ api_proto_library_internal( "//envoy/api/v2/core:base", "//envoy/api/v2/core:health_check", "//envoy/api/v2/endpoint", + "//envoy/type:percent", ], ) @@ -52,6 +53,7 @@ api_go_grpc_library( "//envoy/api/v2/core:base_go_proto", "//envoy/api/v2/core:health_check_go_proto", "//envoy/api/v2/endpoint:endpoint_go_proto", + "//envoy/type:percent_go_proto", ], ) diff --git a/api/envoy/api/v2/eds.proto b/api/envoy/api/v2/eds.proto index 0c63fbaa58484..d4bdc93e16a2c 100644 --- a/api/envoy/api/v2/eds.proto +++ b/api/envoy/api/v2/eds.proto @@ -6,6 +6,7 @@ option java_generic_services = true; import "envoy/api/v2/discovery.proto"; import "envoy/api/v2/endpoint/endpoint.proto"; +import "envoy/type/percent.proto"; import "google/api/annotations.proto"; @@ -50,12 +51,35 @@ message ClusterLoadAssignment { // Load balancing policy settings. message Policy { - // Percentage of traffic (0-100) that should be dropped. This - // action allows protection of upstream hosts should they unable to - // recover from an outage or should they be unable to autoscale and hence - // overall incoming traffic volume need to be trimmed to protect them. - // [#v2-api-diff: This is known as maintenance mode in v1.] - double drop_overload = 1 [(validate.rules).double = {gte: 0, lte: 100}]; + reserved 1; + + message DropOverload { + // Identifier for the policy specifying the drop. + string category = 1 [(validate.rules).string.min_bytes = 1]; + + // Percentage of traffic that should be dropped for the category. + envoy.type.Percent drop_percentage = 2; + } + // Action to trim the overall incoming traffic to protect the upstream + // hosts. This action allows protection in case the hosts are unable to + // recover from an outage, or unable to autoscale or unable to handle + // incoming traffic volume for any reason. + // + // At the client each category is applied one after the other to generate + // the 'actual' drop percentage on all outgoing traffic. For example: + // + // .. code-block:: json + // + // { "drop_overloads": [ + // { "category": "throttle", "drop_percentage": 60 } + // { "category": "lb", "drop_percentage": 50 } + // ]} + // + // The actual drop percentages applied to the traffic at the clients will be + // "throttle"_drop = 60% + // "lb"_drop = 20% // 50% of the remaining 'actual' load, which is 40%. + // actual_outgoing_load = 20% // remaining after applying all categories. + repeated DropOverload drop_overloads = 2; } // Load balancing policy settings. diff --git a/api/envoy/api/v2/endpoint/load_report.proto b/api/envoy/api/v2/endpoint/load_report.proto index 80d8b669d4948..45ca3a168bbaf 100644 --- a/api/envoy/api/v2/endpoint/load_report.proto +++ b/api/envoy/api/v2/endpoint/load_report.proto @@ -96,6 +96,16 @@ message ClusterStats { // deliberately dropped by the drop_overload policy and circuit breaking. uint64 total_dropped_requests = 3; + message DroppedRequests { + // Identifier for the policy specifying the drop. + string category = 1 [(validate.rules).string.min_bytes = 1]; + // Total number of deliberately dropped requests for the category. + uint64 dropped_count = 2; + } + // Information about deliberately dropped requests for each category specified + // in the DropOverload policy. + repeated DroppedRequests dropped_requests = 5; + // Period over which the actual load report occurred. This will be guaranteed to include every // request reported. Due to system load and delays between the *LoadStatsRequest* sent from Envoy // and the *LoadStatsResponse* message sent from the management server, this may be longer than