@@ -77,7 +77,7 @@ func convertPathRuleV1(
7777 ns := metadata .Namespace
7878 name := metadata .Name
7979
80- isZoneTargets := false
80+ zoneTarget := false
8181
8282 if prule .Backend == nil {
8383 return nil , fmt .Errorf ("invalid path rule, missing backend in: %s/%s/%s" , ns , name , host )
@@ -123,7 +123,7 @@ func convertPathRuleV1(
123123 protocol = p
124124 }
125125
126- eps , isZoneTargets = state .GetEndpointsByService (ic .zone , ns , svcName , protocol , servicePort )
126+ eps , zoneTarget = state .GetEndpointsByService (ic .zone , ns , svcName , protocol , servicePort )
127127 }
128128 if len (eps ) == 0 {
129129 ic .logger .Tracef ("Target endpoints not found, shuntroute for %s:%s" , svcName , svcPort )
@@ -155,26 +155,21 @@ func convertPathRuleV1(
155155 }
156156 var r * eskip.Route
157157
158- if isZoneTargets {
158+ r = & eskip.Route {
159+ Id : routeID (ns , name , host , prule .Path , svcName ),
160+ BackendType : eskip .LBBackend ,
161+ LBAlgorithm : getLoadBalancerAlgorithm (metadata , defaultLoadBalancerAlgorithm ),
162+ HostRegexps : hostRegexp ,
163+ }
164+
165+ if zoneTarget {
159166 var lbeps []* eskip.LBEndpoint
160167 for _ , ep := range eps {
161168 lbeps = append (lbeps , & eskip.LBEndpoint {Address : ep , Zone : ic .zone })
162169 }
163- r = & eskip.Route {
164- Id : routeID (ns , name , host , prule .Path , svcName ),
165- BackendType : eskip .LBBackend ,
166- LBEndpoints : lbeps ,
167- LBAlgorithm : getLoadBalancerAlgorithm (metadata , defaultLoadBalancerAlgorithm ),
168- HostRegexps : hostRegexp ,
169- }
170+ r .LBEndpoints = lbeps
170171 } else {
171- r = & eskip.Route {
172- Id : routeID (ns , name , host , prule .Path , svcName ),
173- BackendType : eskip .LBBackend ,
174- LBEndpoints : eskip .NewLBEndpoints (eps ),
175- LBAlgorithm : getLoadBalancerAlgorithm (metadata , defaultLoadBalancerAlgorithm ),
176- HostRegexps : hostRegexp ,
177- }
172+ r .LBEndpoints = eskip .NewLBEndpoints (eps )
178173 }
179174
180175 setPathV1 (pathMode , r , prule .PathType , prule .Path )
@@ -216,12 +211,6 @@ func (ing *ingress) addEndpointsRuleV1(ic *ingressContext, host string, prule *d
216211 return fmt .Errorf ("error while getting service: %w" , err )
217212 }
218213
219- // // check for minEndpointsByZone and set zone for endpoints if needed
220-
221- // for _, lbep := range endpointsRoute.LBEndpoints {
222- // lbep.Zone = ic.zone
223- // }
224-
225214 if endpointsRoute .BackendType != eskip .ShuntBackend {
226215 // safe prepend, see: https://play.golang.org/p/zg5aGKJpRyK
227216 filters := make ([]* eskip.Filter , len (endpointsRoute .Filters )+ len (ic .annotationFilters ))
@@ -380,7 +369,7 @@ func (ing *ingress) convertDefaultBackendV1(
380369 svcName = i .Spec .DefaultBackend .Service .Name
381370 svcPort = i .Spec .DefaultBackend .Service .Port
382371 )
383- isZoneTargets := false
372+ zoneTarget := false
384373
385374 svc , err := state .getService (ns , svcName )
386375 if err != nil {
@@ -408,7 +397,7 @@ func (ing *ingress) convertDefaultBackendV1(
408397 protocol = p
409398 }
410399
411- eps , isZoneTargets = state .GetEndpointsByService (
400+ eps , zoneTarget = state .GetEndpointsByService (
412401 ing .zone ,
413402 ns ,
414403 svcName ,
@@ -434,25 +423,25 @@ func (ing *ingress) convertDefaultBackendV1(
434423 }, true , nil
435424 }
436425
437- if isZoneTargets {
426+ var r * eskip.Route
427+
428+ r = & eskip.Route {
429+ Id : routeID (ns , name , "" , "" , "" ),
430+ BackendType : eskip .LBBackend ,
431+ LBAlgorithm : getLoadBalancerAlgorithm (i .Metadata , ing .defaultLoadBalancerAlgorithm ),
432+ }
433+
434+ if zoneTarget {
438435 var lbeps []* eskip.LBEndpoint
439436 for _ , ep := range eps {
440437 lbeps = append (lbeps , & eskip.LBEndpoint {Address : ep , Zone : ing .zone })
441438 }
442- return & eskip.Route {
443- Id : routeID (ns , name , "" , "" , "" ),
444- BackendType : eskip .LBBackend ,
445- LBEndpoints : lbeps ,
446- LBAlgorithm : getLoadBalancerAlgorithm (i .Metadata , ing .defaultLoadBalancerAlgorithm ),
447- }, true , nil
439+ r .LBEndpoints = lbeps
440+ } else {
441+ r .LBEndpoints = eskip .NewLBEndpoints (eps )
448442 }
449443
450- return & eskip.Route {
451- Id : routeID (ns , name , "" , "" , "" ),
452- BackendType : eskip .LBBackend ,
453- LBEndpoints : eskip .NewLBEndpoints (eps ),
454- LBAlgorithm : getLoadBalancerAlgorithm (i .Metadata , ing .defaultLoadBalancerAlgorithm ),
455- }, true , nil
444+ return r , true , nil
456445}
457446
458447func serviceNameBackend (svcName , svcNamespace string , servicePort * servicePort ) string {
0 commit comments