Skip to content

Commit 05a37e0

Browse files
committed
tmp: review
- default timeouts retrieved once - max timeout computed once
1 parent 5cee412 commit 05a37e0

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

images/router/haproxy/conf/haproxy-config.template

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
{{- $dynamicConfigManager := .DynamicConfigManager }}
1010
{{- $router_ip_v4_v6_mode := env "ROUTER_IP_V4_V6_MODE" "v4" }}
1111
{{- $router_disable_http2 := env "ROUTER_DISABLE_HTTP2" "false" }}
12+
{{- $routerDefaultServerTimeout := env "ROUTER_DEFAULT_SERVER_TIMEOUT" "30s" }}
13+
{{- $routerDefaultTunnelTimeout := env "ROUTER_DEFAULT_TUNNEL_TIMEOUT" "1h" }}
1214
{{- $haveClientCA := .HaveClientCA }}
1315
{{- $haveCRLs := .HaveCRLs }}
1416

@@ -42,6 +44,9 @@
4244
{{- /* pathRewriteTargetPattern: Match path rewrite-Target */}}
4345
{{- $pathRewriteTargetPattern := `^/.*$` -}}
4446

47+
{{- /* Maximum timeout among all the routes, required to be set on the middle backends to avoid warning message about missing server timeout. */}}
48+
{{- $routerMaxServerTimeout := maxTimeoutFirstMatchedAndClipped .State "haproxy.router.openshift.io/timeout" $timeSpecPattern $routerDefaultServerTimeout }}
49+
4550
global
4651
# Drop resource limit checks to mitigate https://issues.redhat.com/browse/OCPBUGS-21803 in HAProxy 2.6.
4752
no strict-limits
@@ -314,8 +319,8 @@ frontend public_ssl
314319
# traffic
315320
##########################################################################
316321
backend be_sni
317-
{{- with $value := maxTimeoutFirstMatchedAndClipped .State "haproxy.router.openshift.io/timeout" $timeSpecPattern (env "ROUTER_DEFAULT_SERVER_TIMEOUT") "30s" }}
318-
timeout server {{ $value }}
322+
{{- with $routerMaxServerTimeout }}
323+
timeout server {{ $routerMaxServerTimeout }}
319324
{{- end }}
320325
server fe_sni unix@/var/lib/haproxy/run/haproxy-sni.sock weight 1 send-proxy
321326

@@ -433,8 +438,8 @@ frontend fe_sni
433438
##########################################################################
434439
# backend for when sni does not exist, or ssl term needs to happen on the edge
435440
backend be_no_sni
436-
{{- with $value := maxTimeoutFirstMatchedAndClipped .State "haproxy.router.openshift.io/timeout" $timeSpecPattern (env "ROUTER_DEFAULT_SERVER_TIMEOUT") "30s" }}
437-
timeout server {{ $value }}
441+
{{- with $routerMaxServerTimeout}}
442+
timeout server {{ $routerMaxServerTimeout }}
438443
{{- end }}
439444
server fe_no_sni unix@/var/lib/haproxy/run/haproxy-no-sni.sock weight 1 send-proxy
440445

@@ -595,11 +600,11 @@ backend {{ genBackendNamePrefix $cfg.TLSTermination }}:{{ $cfgIdx }}
595600
{{- end }}
596601
tcp-request content reject if !whitelist
597602
{{- end }}
598-
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout") (env "ROUTER_DEFAULT_SERVER_TIMEOUT") "30s") }}
599-
timeout server {{ $value }}
603+
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout") $routerDefaultServerTimeout) }}
604+
timeout server {{ $value }}
600605
{{- end }}
601-
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout-tunnel") (env "ROUTER_DEFAULT_TUNNEL_TIMEOUT") "1h") }}
602-
timeout tunnel {{ $value }}
606+
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout-tunnel") $routerDefaultTunnelTimeout) }}
607+
timeout tunnel {{ $value }}
603608
{{- end }}
604609

605610
{{- if isTrue (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}
@@ -799,11 +804,11 @@ backend {{ genBackendNamePrefix $cfg.TLSTermination }}:{{ $cfgIdx }}
799804
{{- end }}
800805
tcp-request content reject if !whitelist
801806
{{- end }}
802-
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout") (env "ROUTER_DEFAULT_SERVER_TIMEOUT") "30s") }}
803-
timeout server {{ $value }}
807+
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout") $routerDefaultServerTimeout) }}
808+
timeout server {{ $value }}
804809
{{- end }}
805-
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout-tunnel") (index $cfg.Annotations "haproxy.router.openshift.io/timeout") (env "ROUTER_DEFAULT_TUNNEL_TIMEOUT") "1h") }}
806-
timeout tunnel {{ $value }}
810+
{{- with $value := clipHAProxyTimeoutValue (firstMatch $timeSpecPattern (index $cfg.Annotations "haproxy.router.openshift.io/timeout-tunnel") (index $cfg.Annotations "haproxy.router.openshift.io/timeout") $routerDefaultTunnelTimeout) }}
811+
timeout tunnel {{ $value }}
807812
{{- end }}
808813

809814
{{- if isTrue (index $cfg.Annotations "haproxy.router.openshift.io/rate-limit-connections") }}

0 commit comments

Comments
 (0)