From 400f32a6c84e61e9e96b538022c5efebe1e3a7e8 Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Sun, 14 Jan 2018 01:52:04 +0000 Subject: [PATCH 1/4] Healthcheck filter: compute response based on upstream cluster health *Description*: Extend the "non pass through" mode of the HTTP health check filter to allow an optional map from cluster names to percentages. If specified, each of the named clusters must have at least the specified percentage of its servers healthy for the filter to return a 200. (The proxy also must be in a non-draining state, or else the filter will return a 503 like it did previously.) Associated envoyproxy/envoy issue: https://github.com/envoyproxy/envoy/issues/2362 Signed-off-by: Brian Pane --- api/filter/http/health_check.proto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/filter/http/health_check.proto b/api/filter/http/health_check.proto index b20ba4601..f83b429ab 100644 --- a/api/filter/http/health_check.proto +++ b/api/filter/http/health_check.proto @@ -21,4 +21,10 @@ message HealthCheck { // If operating in pass through mode, the amount of time in milliseconds // that the filter should cache the upstream response. google.protobuf.Duration cache_time = 3; + + // [#not-implemented-hide:] + // If operating in non pass through mode, specifies a set of upstream cluster + // names and the minimum percentage of servers in each of those clusters that + // must be healthy in order for the filter to return a 200. + map cluster_min_percentages = 4; } From fdc99adc0d6721a55a54d75aad61bed3f538db73 Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Sun, 14 Jan 2018 22:13:53 +0000 Subject: [PATCH 2/4] Updated comments and field names Signed-off-by: Brian Pane --- api/filter/http/health_check.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/filter/http/health_check.proto b/api/filter/http/health_check.proto index f83b429ab..1096f412c 100644 --- a/api/filter/http/health_check.proto +++ b/api/filter/http/health_check.proto @@ -23,8 +23,8 @@ message HealthCheck { google.protobuf.Duration cache_time = 3; // [#not-implemented-hide:] - // If operating in non pass through mode, specifies a set of upstream cluster + // If operating in non-pass-through mode, specifies a set of upstream cluster // names and the minimum percentage of servers in each of those clusters that // must be healthy in order for the filter to return a 200. - map cluster_min_percentages = 4; + map cluster_min_healthy_percentages = 4; } From 06b11c5b51ccedbf624827b722fcaa96bec3bb4d Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Tue, 16 Jan 2018 02:19:00 +0000 Subject: [PATCH 3/4] Add a Percent message type Signed-off-by: Brian Pane --- api/base.proto | 5 +++++ api/filter/http/BUILD | 3 +++ api/filter/http/health_check.proto | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/base.proto b/api/base.proto index cb6743b6f..72c66337e 100644 --- a/api/base.proto +++ b/api/base.proto @@ -35,6 +35,11 @@ message Locality { string sub_zone = 3; } +// Identifies a percentage, in the range [0.0, 100.0]. +message Percent { + double value = 1 [(validate.rules).double = {gte: 0, lte: 100}]; +} + // Identifies a specific Envoy instance. The node identifier is presented to the // management server, which may use this identifier to distinguish per Envoy // configuration for serving. diff --git a/api/filter/http/BUILD b/api/filter/http/BUILD index 7491c013c..5cf22fd02 100644 --- a/api/filter/http/BUILD +++ b/api/filter/http/BUILD @@ -37,6 +37,9 @@ api_proto_library( api_proto_library( name = "health_check", srcs = ["health_check.proto"], + deps = [ + "//api:base", + ], ) api_proto_library( diff --git a/api/filter/http/health_check.proto b/api/filter/http/health_check.proto index 1096f412c..fa8530cb8 100644 --- a/api/filter/http/health_check.proto +++ b/api/filter/http/health_check.proto @@ -5,6 +5,7 @@ package envoy.api.v2.filter.http; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; +import "api/base.proto"; import "validate/validate.proto"; // [#protodoc-title: Health check] @@ -26,5 +27,5 @@ message HealthCheck { // If operating in non-pass-through mode, specifies a set of upstream cluster // names and the minimum percentage of servers in each of those clusters that // must be healthy in order for the filter to return a 200. - map cluster_min_healthy_percentages = 4; + map cluster_min_healthy_percentages = 4; } From 4f68beb4ebbe2584e109ba9e420a7e416fa3002c Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Tue, 16 Jan 2018 21:14:07 +0000 Subject: [PATCH 4/4] Document the new Percent message type in STYLE.md Signed-off-by: Brian Pane --- STYLE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/STYLE.md b/STYLE.md index 624a3c127..94cffa23d 100644 --- a/STYLE.md +++ b/STYLE.md @@ -67,3 +67,5 @@ In addition, the following conventions should be followed: ``` This is more efficient, extendable and self-describing. + +* To represent percentage values, use the Percent message type defined in [api/base.proto](api/base.proto).