Update gce NodeCondition parameter

This commit is contained in:
Manuel de Brito Fontes 2016-07-11 23:43:36 -04:00
parent a736fba0e1
commit a34124be9d
2 changed files with 11 additions and 9 deletions

View file

@ -439,7 +439,8 @@ func (lbc *LoadBalancerController) syncNodes(key string) error {
return nil return nil
} }
func nodeReady(node api.Node) bool { func getNodeReadyPredicate() cache.NodeConditionPredicate {
return func(node *api.Node) bool {
for ix := range node.Status.Conditions { for ix := range node.Status.Conditions {
condition := &node.Status.Conditions[ix] condition := &node.Status.Conditions[ix]
if condition.Type == api.NodeReady { if condition.Type == api.NodeReady {
@ -447,12 +448,13 @@ func nodeReady(node api.Node) bool {
} }
} }
return false return false
}
} }
// getReadyNodeNames returns names of schedulable, ready nodes from the node lister. // getReadyNodeNames returns names of schedulable, ready nodes from the node lister.
func (lbc *LoadBalancerController) getReadyNodeNames() ([]string, error) { func (lbc *LoadBalancerController) getReadyNodeNames() ([]string, error) {
nodeNames := []string{} nodeNames := []string{}
nodes, err := lbc.nodeLister.NodeCondition(nodeReady).List() nodes, err := lbc.nodeLister.NodeCondition(getNodeReadyPredicate()).List()
if err != nil { if err != nil {
return nodeNames, err return nodeNames, err
} }

View file

@ -365,7 +365,7 @@ func getZone(n api.Node) string {
// GetZoneForNode returns the zone for a given node by looking up its zone label. // GetZoneForNode returns the zone for a given node by looking up its zone label.
func (t *GCETranslator) GetZoneForNode(name string) (string, error) { 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 { if err != nil {
return "", err return "", err
} }
@ -382,7 +382,7 @@ func (t *GCETranslator) GetZoneForNode(name string) (string, error) {
// ListZones returns a list of zones this Kubernetes cluster spans. // ListZones returns a list of zones this Kubernetes cluster spans.
func (t *GCETranslator) ListZones() ([]string, error) { func (t *GCETranslator) ListZones() ([]string, error) {
zones := sets.String{} zones := sets.String{}
readyNodes, err := t.nodeLister.NodeCondition(nodeReady).List() readyNodes, err := t.nodeLister.NodeCondition(getNodeReadyPredicate()).List()
if err != nil { if err != nil {
return zones.List(), err return zones.List(), err
} }