Skip to content

Commit f154d30

Browse files
author
Jim Ryan
authored
Fix: GRPC healthcheck should not have keepalive time (#5899)
* fix template file, and fix test * add test for GPRC health check fail message, remove flaky label from prior tests, clean up health check template * update snap * update snapshots * remove newline * fix tests
1 parent b6c8db8 commit f154d30

File tree

11 files changed

+339
-262
lines changed

11 files changed

+339
-262
lines changed

internal/configs/version2/__snapshots__/templates_test.snap

Lines changed: 72 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,18 @@ server {
190190
proxy_read_timeout ;
191191
proxy_send_timeout ;
192192
proxy_pass http://coffee-v2;
193-
health_check uri=/ port=50 interval=5s jitter=0s
194-
fails=1 passes=1
195-
mandatory persistent
196-
keepalive_time=;
197-
}
193+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
194+
195+
}
198196
location @hc-tea {
199197

200198
grpc_connect_timeout ;
201199
grpc_read_timeout ;
202200
grpc_send_timeout ;
203201
grpc_pass grpc://tea-v3;
204-
health_check port=50 interval=5s jitter=0s
205-
fails=1 passes=1
206-
207-
type=grpc grpc_status=12
208-
grpc_service=tea-servicev2 keepalive_time=;
209-
}
202+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
203+
204+
}
210205
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
211206

212207
default_type "application/json";
@@ -627,23 +622,18 @@ server {
627622
proxy_read_timeout ;
628623
proxy_send_timeout ;
629624
proxy_pass http://coffee-v2;
630-
health_check uri=/ port=50 interval=5s jitter=0s
631-
fails=1 passes=1
632-
mandatory persistent
633-
keepalive_time=;
634-
}
625+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
626+
627+
}
635628
location @hc-tea {
636629

637630
grpc_connect_timeout ;
638631
grpc_read_timeout ;
639632
grpc_send_timeout ;
640633
grpc_pass grpc://tea-v3;
641-
health_check port=50 interval=5s jitter=0s
642-
fails=1 passes=1
643-
644-
type=grpc grpc_status=12
645-
grpc_service=tea-servicev2 keepalive_time=;
646-
}
634+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
635+
636+
}
647637
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
648638

649639
default_type "application/json";
@@ -1999,23 +1989,18 @@ server {
19991989
proxy_read_timeout ;
20001990
proxy_send_timeout ;
20011991
proxy_pass http://coffee-v2;
2002-
health_check uri=/ port=50 interval=5s jitter=0s
2003-
fails=1 passes=1
2004-
mandatory persistent
2005-
keepalive_time=;
2006-
}
1992+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
1993+
1994+
}
20071995
location @hc-tea {
20081996

20091997
grpc_connect_timeout ;
20101998
grpc_read_timeout ;
20111999
grpc_send_timeout ;
20122000
grpc_pass grpc://tea-v3;
2013-
health_check port=50 interval=5s jitter=0s
2014-
fails=1 passes=1
2015-
2016-
type=grpc grpc_status=12
2017-
grpc_service=tea-servicev2 keepalive_time=;
2018-
}
2001+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
2002+
2003+
}
20192004
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
20202005

20212006
default_type "application/json";
@@ -2371,23 +2356,18 @@ server {
23712356
proxy_read_timeout ;
23722357
proxy_send_timeout ;
23732358
proxy_pass http://coffee-v2;
2374-
health_check uri=/ port=50 interval=5s jitter=0s
2375-
fails=1 passes=1
2376-
mandatory persistent
2377-
keepalive_time=;
2378-
}
2359+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
2360+
2361+
}
23792362
location @hc-tea {
23802363

23812364
grpc_connect_timeout ;
23822365
grpc_read_timeout ;
23832366
grpc_send_timeout ;
23842367
grpc_pass grpc://tea-v3;
2385-
health_check port=50 interval=5s jitter=0s
2386-
fails=1 passes=1
2387-
2388-
type=grpc grpc_status=12
2389-
grpc_service=tea-servicev2 keepalive_time=;
2390-
}
2368+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
2369+
2370+
}
23912371
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
23922372

23932373
default_type "application/json";
@@ -2800,23 +2780,18 @@ server {
28002780
proxy_read_timeout ;
28012781
proxy_send_timeout ;
28022782
proxy_pass http://coffee-v2;
2803-
health_check uri=/ port=50 interval=5s jitter=0s
2804-
fails=1 passes=1
2805-
mandatory persistent
2806-
keepalive_time=;
2807-
}
2783+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
2784+
2785+
}
28082786
location @hc-tea {
28092787

28102788
grpc_connect_timeout ;
28112789
grpc_read_timeout ;
28122790
grpc_send_timeout ;
28132791
grpc_pass grpc://tea-v3;
2814-
health_check port=50 interval=5s jitter=0s
2815-
fails=1 passes=1
2816-
2817-
type=grpc grpc_status=12
2818-
grpc_service=tea-servicev2 keepalive_time=;
2819-
}
2792+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
2793+
2794+
}
28202795
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
28212796

28222797
default_type "application/json";
@@ -3227,23 +3202,18 @@ server {
32273202
proxy_read_timeout ;
32283203
proxy_send_timeout ;
32293204
proxy_pass http://coffee-v2;
3230-
health_check uri=/ port=50 interval=5s jitter=0s
3231-
fails=1 passes=1
3232-
mandatory persistent
3233-
keepalive_time=;
3234-
}
3205+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
3206+
3207+
}
32353208
location @hc-tea {
32363209

32373210
grpc_connect_timeout ;
32383211
grpc_read_timeout ;
32393212
grpc_send_timeout ;
32403213
grpc_pass grpc://tea-v3;
3241-
health_check port=50 interval=5s jitter=0s
3242-
fails=1 passes=1
3243-
3244-
type=grpc grpc_status=12
3245-
grpc_service=tea-servicev2 keepalive_time=;
3246-
}
3214+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
3215+
3216+
}
32473217
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
32483218

32493219
default_type "application/json";
@@ -3654,23 +3624,18 @@ server {
36543624
proxy_read_timeout ;
36553625
proxy_send_timeout ;
36563626
proxy_pass http://coffee-v2;
3657-
health_check uri=/ port=50 interval=5s jitter=0s
3658-
fails=1 passes=1
3659-
mandatory persistent
3660-
keepalive_time=;
3661-
}
3627+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
3628+
3629+
}
36623630
location @hc-tea {
36633631

36643632
grpc_connect_timeout ;
36653633
grpc_read_timeout ;
36663634
grpc_send_timeout ;
36673635
grpc_pass grpc://tea-v3;
3668-
health_check port=50 interval=5s jitter=0s
3669-
fails=1 passes=1
3670-
3671-
type=grpc grpc_status=12
3672-
grpc_service=tea-servicev2 keepalive_time=;
3673-
}
3636+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
3637+
3638+
}
36743639
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
36753640

36763641
default_type "application/json";
@@ -4083,23 +4048,18 @@ server {
40834048
proxy_read_timeout ;
40844049
proxy_send_timeout ;
40854050
proxy_pass http://coffee-v2;
4086-
health_check uri=/ port=50 interval=5s jitter=0s
4087-
fails=1 passes=1
4088-
mandatory persistent
4089-
keepalive_time=;
4090-
}
4051+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
4052+
4053+
}
40914054
location @hc-tea {
40924055

40934056
grpc_connect_timeout ;
40944057
grpc_read_timeout ;
40954058
grpc_send_timeout ;
40964059
grpc_pass grpc://tea-v3;
4097-
health_check port=50 interval=5s jitter=0s
4098-
fails=1 passes=1
4099-
4100-
type=grpc grpc_status=12
4101-
grpc_service=tea-servicev2 keepalive_time=;
4102-
}
4060+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
4061+
4062+
}
41034063
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
41044064

41054065
default_type "application/json";
@@ -4512,23 +4472,18 @@ server {
45124472
proxy_read_timeout ;
45134473
proxy_send_timeout ;
45144474
proxy_pass http://coffee-v2;
4515-
health_check uri=/ port=50 interval=5s jitter=0s
4516-
fails=1 passes=1
4517-
mandatory persistent
4518-
keepalive_time=;
4519-
}
4475+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
4476+
4477+
}
45204478
location @hc-tea {
45214479

45224480
grpc_connect_timeout ;
45234481
grpc_read_timeout ;
45244482
grpc_send_timeout ;
45254483
grpc_pass grpc://tea-v3;
4526-
health_check port=50 interval=5s jitter=0s
4527-
fails=1 passes=1
4528-
4529-
type=grpc grpc_status=12
4530-
grpc_service=tea-servicev2 keepalive_time=;
4531-
}
4484+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
4485+
4486+
}
45324487
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
45334488

45344489
default_type "application/json";
@@ -4941,23 +4896,18 @@ server {gunzip on;
49414896
proxy_read_timeout ;
49424897
proxy_send_timeout ;
49434898
proxy_pass http://coffee-v2;
4944-
health_check uri=/ port=50 interval=5s jitter=0s
4945-
fails=1 passes=1
4946-
mandatory persistent
4947-
keepalive_time=;
4948-
}
4899+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
4900+
4901+
}
49494902
location @hc-tea {
49504903

49514904
grpc_connect_timeout ;
49524905
grpc_read_timeout ;
49534906
grpc_send_timeout ;
49544907
grpc_pass grpc://tea-v3;
4955-
health_check port=50 interval=5s jitter=0s
4956-
fails=1 passes=1
4957-
4958-
type=grpc grpc_status=12
4959-
grpc_service=tea-servicev2 keepalive_time=;
4960-
}
4908+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
4909+
4910+
}
49614911
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
49624912

49634913
default_type "application/json";
@@ -5370,23 +5320,18 @@ server {
53705320
proxy_read_timeout ;
53715321
proxy_send_timeout ;
53725322
proxy_pass http://coffee-v2;
5373-
health_check uri=/ port=50 interval=5s jitter=0s
5374-
fails=1 passes=1
5375-
mandatory persistent
5376-
keepalive_time=;
5377-
}
5323+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
5324+
5325+
}
53785326
location @hc-tea {
53795327

53805328
grpc_connect_timeout ;
53815329
grpc_read_timeout ;
53825330
grpc_send_timeout ;
53835331
grpc_pass grpc://tea-v3;
5384-
health_check port=50 interval=5s jitter=0s
5385-
fails=1 passes=1
5386-
5387-
type=grpc grpc_status=12
5388-
grpc_service=tea-servicev2 keepalive_time=;
5389-
}
5332+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
5333+
5334+
}
53905335
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
53915336

53925337
default_type "application/json";
@@ -6243,23 +6188,18 @@ server {
62436188
proxy_read_timeout ;
62446189
proxy_send_timeout ;
62456190
proxy_pass http://coffee-v2;
6246-
health_check uri=/ port=50 interval=5s jitter=0s
6247-
fails=1 passes=1
6248-
mandatory persistent
6249-
keepalive_time=;
6250-
}
6191+
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;
6192+
6193+
}
62516194
location @hc-tea {
62526195

62536196
grpc_connect_timeout ;
62546197
grpc_read_timeout ;
62556198
grpc_send_timeout ;
62566199
grpc_pass grpc://tea-v3;
6257-
health_check port=50 interval=5s jitter=0s
6258-
fails=1 passes=1
6259-
6260-
type=grpc grpc_status=12
6261-
grpc_service=tea-servicev2 keepalive_time=;
6262-
}
6200+
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;
6201+
6202+
}
62636203
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {
62646204

62656205
default_type "application/json";

internal/configs/version2/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ type HealthCheck struct {
286286
Mandatory bool
287287
Persistent bool
288288
KeepaliveTime string
289+
IsGRPC bool
289290
}
290291

291292
// TLSRedirect defines a redirect in a Server.

internal/configs/version2/nginx-plus.virtualserver.tmpl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,17 @@ server {
332332
{{- else }}
333333
proxy_pass {{ $hc.ProxyPass }};
334334
{{- end }}
335-
health_check {{ if $hc.URI }}uri={{ $hc.URI }} {{ end }}{{ if $hc.Port }}port={{ $hc.Port }} {{ end }}interval={{ $hc.Interval }} jitter={{ $hc.Jitter }}
336-
fails={{ $hc.Fails }} passes={{ $hc.Passes }}{{ if $hc.Match }} match={{ $hc.Match }}{{ end }}
337-
{{ if $hc.Mandatory }} mandatory{{ if $hc.Persistent }} persistent{{ end }}{{ end }}
338-
{{ if $hc.GRPCPass }} type=grpc{{ if $hc.GRPCStatus }} grpc_status={{ $hc.GRPCStatus }}{{ end }}
339-
{{ if $hc.GRPCService }} grpc_service={{ $hc.GRPCService }}{{ end }}{{ end }} keepalive_time={{ $hc.KeepaliveTime }};
340-
}
335+
health_check{{- if $hc.URI }} uri={{ $hc.URI }} {{ end -}}
336+
{{- if $hc.Port }} port={{ $hc.Port }} {{ end -}}
337+
interval={{ $hc.Interval }} jitter={{ $hc.Jitter }} fails={{ $hc.Fails }} passes={{ $hc.Passes }}
338+
{{- if $hc.Match }} match={{ $hc.Match }}{{- end -}}
339+
{{- if $hc.Mandatory }} mandatory {{ end -}}
340+
{{- if $hc.Persistent }} persistent {{ end -}}
341+
{{- if not $hc.IsGRPC }} keepalive_time={{ $hc.KeepaliveTime }}{{ end -}}
342+
{{- if $hc.GRPCPass }} type=grpc{{- if $hc.GRPCStatus }} grpc_status={{ $hc.GRPCStatus }}{{- end -}}
343+
{{- if $hc.GRPCService }} grpc_service={{ $hc.GRPCService }}{{- end -}}{{ end -}};
344+
345+
}
341346
{{- end }}
342347

343348
{{- range $e := $s.ErrorPageLocations }}

0 commit comments

Comments
 (0)