From 3d7c44735a6fe792ad7fc9f074034a260e53bb0d Mon Sep 17 00:00:00 2001 From: Owen Marshall Date: Wed, 10 Aug 2016 12:19:02 -0400 Subject: [PATCH] Reorder sticky session definitions --- server.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server.go b/server.go index d8c728c2b..68deee605 100644 --- a/server.go +++ b/server.go @@ -546,20 +546,21 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo } stickysession := configuration.Backends[frontend.Backend].LoadBalancer.Sticky - if stickysession { - sticky := roundrobin.NewStickySession(cookiename) - cookiename := "_TRAEFIK_SERVERNAME" + var cookiename string + var sticky *roundrobin.StickySession + if stickysession { + sticky = roundrobin.NewStickySession(cookiename) + cookiename = "_TRAEFIK_SERVERNAME" } switch lbMethod { case types.Drr: log.Debugf("Creating load-balancer drr") + rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger)) if stickysession { log.Debugf("... setting to sticky session with cookie named %v", cookiename) - rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger), roundrobin.RebalancerStickySession(sticky)) - } else { - rebalancer, _ := roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger)) + rebalancer, _ = roundrobin.NewRebalancer(rr, roundrobin.RebalancerLogger(oxyLogger), roundrobin.RebalancerStickySession(sticky)) } lb = rebalancer for serverName, server := range configuration.Backends[frontend.Backend].Servers {