Skip to content

Commit

Permalink
[cherry-pick] Fix: GRPC healthcheck should not have keepalive time (#…
Browse files Browse the repository at this point in the history
…5921)

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

Co-authored-by: Jim Ryan <j.ryan@f5.com>
  • Loading branch information
nginx-bot and j1m-ryan committed Jul 2, 2024
1 parent c8c72e9 commit 459d4d3
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 262 deletions.
204 changes: 72 additions & 132 deletions internal/configs/version2/__snapshots__/templates_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -627,23 +622,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -1999,23 +1989,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -2371,23 +2356,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -2800,23 +2780,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -3227,23 +3202,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -3654,23 +3624,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -4083,23 +4048,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -4512,23 +4472,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -4941,23 +4896,18 @@ server {gunzip on;
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -5370,23 +5320,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down Expand Up @@ -6243,23 +6188,18 @@ server {
proxy_read_timeout ;
proxy_send_timeout ;
proxy_pass http://coffee-v2;
health_check uri=/ port=50 interval=5s jitter=0s
fails=1 passes=1
mandatory persistent
keepalive_time=;
}
health_check uri=/ port=50 interval=5s jitter=0s fails=1 passes=1 mandatory persistent keepalive_time=60s;

}
location @hc-tea {

grpc_connect_timeout ;
grpc_read_timeout ;
grpc_send_timeout ;
grpc_pass grpc://tea-v3;
health_check port=50 interval=5s jitter=0s
fails=1 passes=1

type=grpc grpc_status=12
grpc_service=tea-servicev2 keepalive_time=;
}
health_check port=50 interval=5s jitter=0s fails=1 passes=1 type=grpc grpc_status=12 grpc_service=tea-servicev2;

}
location @vs_cafe_cafe_vsr_tea_tea_tea__tea_error_page_0 {

default_type "application/json";
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version2/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ type HealthCheck struct {
Mandatory bool
Persistent bool
KeepaliveTime string
IsGRPC bool
}

// TLSRedirect defines a redirect in a Server.
Expand Down
17 changes: 11 additions & 6 deletions internal/configs/version2/nginx-plus.virtualserver.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,17 @@ server {
{{- else }}
proxy_pass {{ $hc.ProxyPass }};
{{- end }}
health_check {{ if $hc.URI }}uri={{ $hc.URI }} {{ end }}{{ if $hc.Port }}port={{ $hc.Port }} {{ end }}interval={{ $hc.Interval }} jitter={{ $hc.Jitter }}
fails={{ $hc.Fails }} passes={{ $hc.Passes }}{{ if $hc.Match }} match={{ $hc.Match }}{{ end }}
{{ if $hc.Mandatory }} mandatory{{ if $hc.Persistent }} persistent{{ end }}{{ end }}
{{ if $hc.GRPCPass }} type=grpc{{ if $hc.GRPCStatus }} grpc_status={{ $hc.GRPCStatus }}{{ end }}
{{ if $hc.GRPCService }} grpc_service={{ $hc.GRPCService }}{{ end }}{{ end }} keepalive_time={{ $hc.KeepaliveTime }};
}
health_check{{- if $hc.URI }} uri={{ $hc.URI }} {{ end -}}
{{- if $hc.Port }} port={{ $hc.Port }} {{ end -}}
interval={{ $hc.Interval }} jitter={{ $hc.Jitter }} fails={{ $hc.Fails }} passes={{ $hc.Passes }}
{{- if $hc.Match }} match={{ $hc.Match }}{{- end -}}
{{- if $hc.Mandatory }} mandatory {{ end -}}
{{- if $hc.Persistent }} persistent {{ end -}}
{{- if not $hc.IsGRPC }} keepalive_time={{ $hc.KeepaliveTime }}{{ end -}}
{{- if $hc.GRPCPass }} type=grpc{{- if $hc.GRPCStatus }} grpc_status={{ $hc.GRPCStatus }}{{- end -}}
{{- if $hc.GRPCService }} grpc_service={{ $hc.GRPCService }}{{- end -}}{{ end -}};

}
{{- end }}

{{- range $e := $s.ErrorPageLocations }}
Expand Down
Loading

0 comments on commit 459d4d3

Please sign in to comment.