diff --git a/pkg/controller/translator/translator.go b/pkg/controller/translator/translator.go index 20e8a57eee..dde4322851 100644 --- a/pkg/controller/translator/translator.go +++ b/pkg/controller/translator/translator.go @@ -36,11 +36,20 @@ import ( "k8s.io/ingress-gce/pkg/backendconfig" "k8s.io/ingress-gce/pkg/context" "k8s.io/ingress-gce/pkg/controller/errors" - "k8s.io/ingress-gce/pkg/loadbalancers" "k8s.io/ingress-gce/pkg/utils" namer_util "k8s.io/ingress-gce/pkg/utils/namer" ) +const ( + // DefaultHost is the host used if none is specified. It is a valid value + // for the "Host" field recognized by GCE. + DefaultHost = "*" + + // DefaultPath is the path used if none is specified. It is a valid path + // recognized by GCE. + DefaultPath = "/*" +) + // getServicePortParams allows for passing parameters to getServicePort() type getServicePortParams struct { isL7ILB bool @@ -206,14 +215,14 @@ func (t *Translator) TranslateIngress(ing *v1beta1.Ingress, systemDefaultBackend // sent to one of the last backend in the rules list. path := p.Path if path == "" { - path = loadbalancers.DefaultPath + path = DefaultPath } pathRules = append(pathRules, utils.PathRule{Path: path, Backend: *svcPort}) } } host := rule.Host if host == "" { - host = loadbalancers.DefaultHost + host = DefaultHost } urlMap.PutPathRulesForHost(host, pathRules) } @@ -266,9 +275,13 @@ func (t *Translator) GetZoneForNode(name string) (string, error) { // ListZones returns a list of zones this Kubernetes cluster spans. func (t *Translator) ListZones() ([]string, error) { - zones := sets.String{} nodeLister := t.ctx.NodeInformer.GetIndexer() - readyNodes, err := listers.NewNodeLister(nodeLister).ListWithPredicate(utils.GetNodeConditionPredicate()) + return t.ListZonesWithLister(listers.NewNodeLister(nodeLister)) +} + +func (t *Translator) ListZonesWithLister(lister listers.NodeLister) ([]string, error) { + zones := sets.String{} + readyNodes, err := lister.ListWithPredicate(utils.GetNodeConditionPredicate()) if err != nil { return zones.List(), err } @@ -276,6 +289,7 @@ func (t *Translator) ListZones() ([]string, error) { zones.Insert(getZone(n)) } return zones.List(), nil + } // geHTTPProbe returns the http readiness probe from the first container diff --git a/pkg/loadbalancers/l7.go b/pkg/loadbalancers/l7.go index af5e1ee045..74ebdf90b2 100644 --- a/pkg/loadbalancers/l7.go +++ b/pkg/loadbalancers/l7.go @@ -40,14 +40,6 @@ import ( ) const ( - // DefaultHost is the host used if none is specified. It is a valid value - // for the "Host" field recognized by GCE. - DefaultHost = "*" - - // DefaultPath is the path used if none is specified. It is a valid path - // recognized by GCE. - DefaultPath = "/*" - invalidConfigErrorMessage = "invalid ingress frontend configuration, please check your usage of the 'kubernetes.io/ingress.allow-http' annotation." )