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

TranslateIngress changes #275

Merged
merged 1 commit into from
May 18, 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
20 changes: 8 additions & 12 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func NewLoadBalancerController(
if ctx.EndpointInformer != nil {
endpointIndexer = ctx.EndpointInformer.GetIndexer()
}
lbc.Translator = translator.NewTranslator(lbc.ctx, lbc.CloudClusterManager.ClusterNamer,
lbc.Translator = translator.NewTranslator(lbc.CloudClusterManager.ClusterNamer,
ctx.ServiceInformer.GetIndexer(),
ctx.NodeInformer.GetIndexer(),
ctx.PodInformer.GetIndexer(),
Expand Down Expand Up @@ -315,7 +315,7 @@ func (lbc *LoadBalancerController) sync(key string) (retErr error) {
}
ing = ing.DeepCopy()

ensureErr := lbc.ensureIngress(key, ing, nodeNames, gceSvcPorts)
ensureErr := lbc.ensureIngress(ing, nodeNames, gceSvcPorts)
if ensureErr != nil {
lbc.ctx.Recorder(ing.Namespace).Eventf(ing, apiv1.EventTypeWarning, "Sync", fmt.Sprintf("Error during sync: %v", ensureErr.Error()))
}
Expand All @@ -330,10 +330,10 @@ func (lbc *LoadBalancerController) sync(key string) (retErr error) {
return ensureErr
}

func (lbc *LoadBalancerController) ensureIngress(key string, ing *extensions.Ingress, nodeNames []string, gceSvcPorts []utils.ServicePort) error {
urlMap, err := lbc.Translator.TranslateIngress(ing, lbc.CloudClusterManager.defaultBackendSvcPortID)
if err != nil {
return fmt.Errorf("error while evaluating the ingress spec: %v", err)
func (lbc *LoadBalancerController) ensureIngress(ing *extensions.Ingress, nodeNames []string, gceSvcPorts []utils.ServicePort) error {
urlMap, errs := lbc.Translator.TranslateIngress(ing, lbc.CloudClusterManager.defaultBackendSvcPortID)
if errs != nil {
return fmt.Errorf("error while evaluating the ingress spec: %v", joinErrs(errs))
}

ingSvcPorts := urlMap.AllServicePorts()
Expand Down Expand Up @@ -395,7 +395,7 @@ func (lbc *LoadBalancerController) ensureIngress(key string, ing *extensions.Ing
}

// Update the UrlMap of the single loadbalancer that came through the watch.
l7, err := lbc.CloudClusterManager.l7Pool.Get(key)
l7, err := lbc.CloudClusterManager.l7Pool.Get(lb.Name)
if err != nil {
return fmt.Errorf("unable to get loadbalancer: %v", err)
}
Expand Down Expand Up @@ -497,11 +497,7 @@ func updateAnnotations(client kubernetes.Interface, name, namespace string, anno
func (lbc *LoadBalancerController) ToSvcPorts(ings *extensions.IngressList) []utils.ServicePort {
var knownPorts []utils.ServicePort
for _, ing := range ings.Items {
urlMap, err := lbc.Translator.TranslateIngress(&ing, lbc.CloudClusterManager.defaultBackendSvcPortID)
if err != nil {
glog.V(4).Infof("ingress %v/%v could not be translated: %v", ing.Namespace, ing.Name, err)
continue
}
urlMap, _ := lbc.Translator.TranslateIngress(&ing, lbc.CloudClusterManager.defaultBackendSvcPortID)
knownPorts = append(knownPorts, urlMap.AllServicePorts()...)
}
return knownPorts
Expand Down
Loading