From f3e9292c046de23f32cef84397f8e563ad1313d5 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sat, 2 Jun 2018 15:17:14 -0400 Subject: [PATCH 1/2] Always sort upstream list to provide stable iteration order --- internal/ingress/controller/controller.go | 10 ++++------ internal/ingress/types_equals.go | 9 --------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index c50d615d01..b543a332bd 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -572,12 +572,6 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([] aUpstreams = append(aUpstreams, upstream) } - if n.cfg.SortBackends { - sort.SliceStable(aUpstreams, func(a, b int) bool { - return aUpstreams[a].Name < aUpstreams[b].Name - }) - } - aServers := make([]*ingress.Server, 0, len(servers)) for _, value := range servers { sort.SliceStable(value.Locations, func(i, j int) bool { @@ -586,6 +580,10 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([] aServers = append(aServers, value) } + sort.SliceStable(aUpstreams, func(a, b int) bool { + return aUpstreams[a].Name < aUpstreams[b].Name + }) + sort.SliceStable(aServers, func(i, j int) bool { return aServers[i].Hostname < aServers[j].Hostname }) diff --git a/internal/ingress/types_equals.go b/internal/ingress/types_equals.go index c0018592e2..359d74a111 100644 --- a/internal/ingress/types_equals.go +++ b/internal/ingress/types_equals.go @@ -129,9 +129,6 @@ func (b1 *Backend) Equal(b2 *Backend) bool { if b1.Service.GetName() != b2.Service.GetName() { return false } - if b1.Service.GetResourceVersion() != b2.Service.GetResourceVersion() { - return false - } } if b1.Port != b2.Port { @@ -326,9 +323,6 @@ func (l1 *Location) Equal(l2 *Location) bool { if l1.Service.GetName() != l2.Service.GetName() { return false } - if l1.Service.GetResourceVersion() != l2.Service.GetResourceVersion() { - return false - } } if l1.Port.StrVal != l2.Port.StrVal { @@ -424,9 +418,6 @@ func (ptb1 *SSLPassthroughBackend) Equal(ptb2 *SSLPassthroughBackend) bool { if ptb1.Service.GetName() != ptb2.Service.GetName() { return false } - if ptb1.Service.GetResourceVersion() != ptb2.Service.GetResourceVersion() { - return false - } } return true From 631edb30d9f7437e5b4cb91ff6d606fa6f0cf2e3 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sat, 2 Jun 2018 17:34:49 -0400 Subject: [PATCH 2/2] Update documentation for sort-backends flag --- cmd/nginx/flags.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/nginx/flags.go b/cmd/nginx/flags.go index 79217778d2..80a8060135 100644 --- a/cmd/nginx/flags.go +++ b/cmd/nginx/flags.go @@ -101,8 +101,7 @@ func parseFlags() (bool, *controller.Configuration, error) { ingress controller should update the Ingress status IP/hostname when the controller is being stopped. Default is true`) - sortBackends = flags.Bool("sort-backends", false, - `Defines if backends and its endpoints should be sorted`) + sortBackends = flags.Bool("sort-backends", false, `Defines if servers inside NGINX upstream should be sorted`) useNodeInternalIP = flags.Bool("report-node-internal-ip-address", false, `Defines if the nodes IP address to be returned in the ingress status should be the internal instead of the external IP address`)