Skip to content

Commit

Permalink
Merge pull request #199 from MrHohn/ensure-ig-nodeports
Browse files Browse the repository at this point in the history
Ensure only needed nodeports on instance group on ingress sync
  • Loading branch information
nicksardo authored Apr 10, 2018
2 parents 094dfba + fc93d1b commit 8b08182
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8b08182

Please sign in to comment.