From fc93d1bdc2bdd35f84ab62626ab9e51294c9f1ca Mon Sep 17 00:00:00 2001 From: Zihong Zheng Date: Tue, 10 Apr 2018 12:01:20 -0700 Subject: [PATCH] Ensure only needed nodeports on instance group on ingress sync --- pkg/controller/controller.go | 9 ++------- pkg/controller/translator/translator.go | 8 ++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 5076c27205..4458e41c24 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -238,17 +238,11 @@ func (lbc *LoadBalancerController) sync(key string) (retErr error) { } glog.V(3).Infof("Syncing %v", key) - allIngresses, err := lbc.ingLister.ListAll() - if err != nil { - return err - } gceIngresses, err := lbc.ingLister.ListGCEIngresses() if err != nil { return err } - // allNodePorts contains ServicePorts used by all ingresses (single-cluster and multi-cluster). - allNodePorts := lbc.Translator.ToNodePorts(&allIngresses) // gceNodePorts contains the ServicePorts used by only single-cluster ingress. gceNodePorts := lbc.Translator.ToNodePorts(&gceIngresses) nodeNames, err := getReadyNodeNames(listers.NewNodeLister(lbc.nodeLister)) @@ -286,7 +280,8 @@ func (lbc *LoadBalancerController) sync(key string) (retErr error) { } }() - igs, err := lbc.CloudClusterManager.EnsureInstanceGroupsAndPorts(nodeNames, allNodePorts) + ingNodePorts := lbc.Translator.IngressToNodePorts(ing) + igs, err := lbc.CloudClusterManager.EnsureInstanceGroupsAndPorts(nodeNames, ingNodePorts) if err != nil { return err } diff --git a/pkg/controller/translator/translator.go b/pkg/controller/translator/translator.go index ea575664a1..a5f1fa475b 100644 --- a/pkg/controller/translator/translator.go +++ b/pkg/controller/translator/translator.go @@ -223,17 +223,17 @@ PortLoop: return p, nil } -// ToNodePorts is a helper method over ingressToNodePorts to process a list of ingresses. +// ToNodePorts is a helper method over IngressToNodePorts to process a list of ingresses. func (t *GCE) ToNodePorts(ings *extensions.IngressList) []backends.ServicePort { var knownPorts []backends.ServicePort for _, ing := range ings.Items { - knownPorts = append(knownPorts, t.ingressToNodePorts(&ing)...) + knownPorts = append(knownPorts, t.IngressToNodePorts(&ing)...) } return knownPorts } -// ingressToNodePorts converts a pathlist to a flat list of nodeports for the given ingress. -func (t *GCE) ingressToNodePorts(ing *extensions.Ingress) []backends.ServicePort { +// IngressToNodePorts converts a pathlist to a flat list of nodeports for the given ingress. +func (t *GCE) IngressToNodePorts(ing *extensions.Ingress) []backends.ServicePort { var knownPorts []backends.ServicePort defaultBackend := ing.Spec.Backend if defaultBackend != nil {