Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure only needed nodeports on instance group on ingress sync #199

Merged
merged 1 commit into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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