From a34124be9d9efacd45cad86be60df7f86f482332 Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Mon, 11 Jul 2016 23:43:36 -0400 Subject: [PATCH] Update gce NodeCondition parameter --- controllers/gce/controller/controller.go | 16 +++++++++------- controllers/gce/controller/utils.go | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/controllers/gce/controller/controller.go b/controllers/gce/controller/controller.go index 82143ac80..14f705c23 100644 --- a/controllers/gce/controller/controller.go +++ b/controllers/gce/controller/controller.go @@ -439,20 +439,22 @@ func (lbc *LoadBalancerController) syncNodes(key string) error { return nil } -func nodeReady(node api.Node) bool { - for ix := range node.Status.Conditions { - condition := &node.Status.Conditions[ix] - if condition.Type == api.NodeReady { - return condition.Status == api.ConditionTrue +func getNodeReadyPredicate() cache.NodeConditionPredicate { + return func(node *api.Node) bool { + for ix := range node.Status.Conditions { + condition := &node.Status.Conditions[ix] + if condition.Type == api.NodeReady { + return condition.Status == api.ConditionTrue + } } + return false } - return false } // getReadyNodeNames returns names of schedulable, ready nodes from the node lister. func (lbc *LoadBalancerController) getReadyNodeNames() ([]string, error) { nodeNames := []string{} - nodes, err := lbc.nodeLister.NodeCondition(nodeReady).List() + nodes, err := lbc.nodeLister.NodeCondition(getNodeReadyPredicate()).List() if err != nil { return nodeNames, err } diff --git a/controllers/gce/controller/utils.go b/controllers/gce/controller/utils.go index 1d9cdc092..298c17978 100644 --- a/controllers/gce/controller/utils.go +++ b/controllers/gce/controller/utils.go @@ -365,7 +365,7 @@ func getZone(n api.Node) string { // GetZoneForNode returns the zone for a given node by looking up its zone label. func (t *GCETranslator) GetZoneForNode(name string) (string, error) { - nodes, err := t.nodeLister.NodeCondition(nodeReady).List() + nodes, err := t.nodeLister.NodeCondition(getNodeReadyPredicate()).List() if err != nil { return "", err } @@ -382,7 +382,7 @@ func (t *GCETranslator) GetZoneForNode(name string) (string, error) { // ListZones returns a list of zones this Kubernetes cluster spans. func (t *GCETranslator) ListZones() ([]string, error) { zones := sets.String{} - readyNodes, err := t.nodeLister.NodeCondition(nodeReady).List() + readyNodes, err := t.nodeLister.NodeCondition(getNodeReadyPredicate()).List() if err != nil { return zones.List(), err }