From 9a22135671e9412cee69e898bf5910c116892fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Thu, 31 May 2018 16:01:50 +0200 Subject: [PATCH] Using an OpenShift route with several services setup for A/B testing, and the "oc set route-backends", setting a zero weigth to a service removes the endpoints from the haproxy backend. This results in a loss of all existing connections, and a loss of associated end-users sessions. Changing: {{ if ne $weight 0 }} to {{ if ge $weight 0 }} fixes the issue. Removing older services is then done whith the "set route-backend" command. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1584701 --- images/router/haproxy/conf/haproxy-config.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/router/haproxy/conf/haproxy-config.template b/images/router/haproxy/conf/haproxy-config.template index 00998bebfd54..72cdeec8ac01 100644 --- a/images/router/haproxy/conf/haproxy-config.template +++ b/images/router/haproxy/conf/haproxy-config.template @@ -377,7 +377,7 @@ backend be_secure:{{$cfgIdx}} {{- end }}{{/* is "edge" or "reencrypt" */}} {{- range $serviceUnitName, $weight := $cfg.ServiceUnitNames }} - {{- if ne $weight 0 }} + {{- if ge $weight 0 }}{{/* weight=0 is reasonable to keep existing connections to backends with cookies as we can see the HTTP headers */}} {{- with $serviceUnit := index $.ServiceUnits $serviceUnitName }} {{- range $idx, $endpoint := processEndpointsForAlias $cfg $serviceUnit (env "ROUTER_BACKEND_PROCESS_ENDPOINTS" "") }} server {{$endpoint.ID}} {{$endpoint.IP}}:{{$endpoint.Port}} cookie {{$endpoint.IdHash}} weight {{$weight}} @@ -446,7 +446,7 @@ backend be_tcp:{{$cfgIdx}} hash-type consistent timeout check 5000ms {{- range $serviceUnitName, $weight := $cfg.ServiceUnitNames }} - {{- if ne $weight 0 }} + {{- if ne $weight 0 }}}{{/* drop connections where weight=0 as we can't use cookies, leaving only r-r and src-ip as dispatch methods and weight make no sense there */}} {{- with $serviceUnit := index $.ServiceUnits $serviceUnitName }} {{- range $idx, $endpoint := processEndpointsForAlias $cfg $serviceUnit (env "ROUTER_BACKEND_PROCESS_ENDPOINTS" "") }} server {{$endpoint.ID}} {{$endpoint.IP}}:{{$endpoint.Port}} weight {{$weight}}