Skip to content

Commit

Permalink
skip sorting upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett Wagner committed Apr 6, 2017
1 parent 374535a commit 53c6509
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ingress/controllers/nginx/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ Default is true
**upstream-fail-timeout:** Sets the time during which the specified number of unsuccessful attempts to communicate with the [server](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream) should happen to consider the server unavailable


**upstream-skip-sort:** Setting this to 'true' stops the controller from sorting the upstreams by IP. This may help with unbalanced sticky sessions.


**use-proxy-protocol:** Enables or disables the use of the [PROXY protocol](https://www.nginx.com/resources/admin-guide/proxy-protocol/) to receive client connection (real IP address) information passed through proxy servers and load balancers such as HAproxy and Amazon Elastic Load Balancer (ELB).


Expand Down
6 changes: 5 additions & 1 deletion ingress/controllers/nginx/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,11 @@ func (lbc *loadBalancerController) getUpstreamServers(ngxCfg config.Configuratio
glog.Warningf("upstream %v does not have any active endpoints. Using default backend", value.Name)
value.Backends = append(value.Backends, nginx.NewDefaultServer())
}
sort.Sort(nginx.UpstreamServerByAddrPort(value.Backends))

if ngxCfg.UpstreamSkipSort != true {
sort.Sort(nginx.UpstreamServerByAddrPort(value.Backends))
}

aUpstreams = append(aUpstreams, value)
}
sort.Sort(nginx.UpstreamByNameServers(aUpstreams))
Expand Down
6 changes: 6 additions & 0 deletions ingress/controllers/nginx/nginx/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ type Configuration struct {
// Default: 0, ie use platform liveness probe
UpstreamFailTimeout int `structs:"upstream-fail-timeout,omitempty"`

// Stops the controller from sorting the upstreams by ip address
// I suspect this will help with an issue in sticky sessions where the traffic is not
// evenly distributed.
// Default: false, sort the upstream
UpstreamSkipSort bool `structs:"upstream-skip-sort,omitempty"`

// Enables or disables the use of the PROXY protocol to receive client connection
// (real IP address) information passed through proxy servers and load balancers
// such as HAproxy and Amazon Elastic Load Balancer (ELB).
Expand Down

0 comments on commit 53c6509

Please sign in to comment.