From 35d99d0c818281dc557a6849a707a6d9b16b14da Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Tue, 18 Feb 2014 10:33:30 -0500 Subject: [PATCH] Implement sticky/persistent session with HAProxy This commit implements sticky/persisten session between HAProxy and Horizon based on the leastconn fashion Related to #237 (cherry picked from commit 1a64e535b7f1a13c6ccd6388a0c95131a91f77eb) Conflicts: manifests/loadbalancer.pp --- manifests/dashboard.pp | 2 +- manifests/loadbalancer.pp | 1 + manifests/loadbalancer/listen_http.pp | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp index 5d2c901d..4a35d2c4 100644 --- a/manifests/dashboard.pp +++ b/manifests/dashboard.pp @@ -138,7 +138,7 @@ class cloud::dashboard( server_names => $::hostname, ipaddresses => $api_eth, ports => $horizon_port, - options => 'check inter 2000 rise 2 fall 5' + options => "check inter 2000 rise 2 fall 5 cookie ${::hostname}" } diff --git a/manifests/loadbalancer.pp b/manifests/loadbalancer.pp index 58962f65..e607da59 100644 --- a/manifests/loadbalancer.pp +++ b/manifests/loadbalancer.pp @@ -522,6 +522,7 @@ class cloud::loadbalancer( 'horizon_cluster': ports => $horizon_port, httpchk => "httpchk GET / HTTP/1.0\r\nUser-Agent:\ ${::hostname}", + options => {'cookie' => 'sessionid prefix', 'balance' => 'leastconn' }, listen_ip => $vip_public_ip; } } diff --git a/manifests/loadbalancer/listen_http.pp b/manifests/loadbalancer/listen_http.pp index 9d281d58..63bc0b8e 100644 --- a/manifests/loadbalancer/listen_http.pp +++ b/manifests/loadbalancer/listen_http.pp @@ -20,16 +20,19 @@ define cloud::loadbalancer::listen_http( $ports = 'unset', $httpchk = 'httpchk', + $options = {}, $listen_ip = '0.0.0.0') { + $options_basic = {'mode' => 'http', + 'balance' => 'roundrobin', + 'http-check' => 'expect ! rstatus ^5', + 'option' => ['tcpka', 'tcplog', $httpchk] } + + $options_custom = merge($options_basic, $options) + haproxy::listen { $name: ipaddress => $listen_ip, ports => $ports, - options => { - 'mode' => 'http', - 'balance' => 'roundrobin', - 'option' => ['tcpka', 'tcplog', $httpchk], - 'http-check' => 'expect ! rstatus ^5', - } + options => $options_custom, } }