Revolyssup commented on code in PR #2553:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2553#discussion_r2347360896


##########
internal/adc/translator/apisixroute.go:
##########
@@ -364,14 +389,26 @@ func (t *Translator) 
translateApisixRouteStreamBackendResolveGranularity(tctx *p
 }
 
 func (t *Translator) 
translateApisixRouteBackendResolveGranularityEndpoint(tctx 
*provider.TranslateContext, arNN types.NamespacedName, backend 
apiv2.ApisixRouteHTTPBackend) (adc.UpstreamNodes, error) {
+       serviceNN := types.NamespacedName{
+               Namespace: arNN.Namespace,
+               Name:      backend.ServiceName,
+       }
+       svc, ok := tctx.Services[serviceNN]
+       if !ok {
+               return nil, errors.Errorf("service not found, ApisixRoute: %s, 
Service: %s", arNN, serviceNN)
+       }
+       port, err := getPortFromService(svc, backend.ServicePort)

Review Comment:
   @bzp2010 Actually this has to be service port only. 
   - In the case of endpoint granularity, we first generate the BackendRef 
object which is a service.
   - Then translateBackendRef is called with the Service and here 
https://github.com/apache/apisix-ingress-controller/blob/476783aab6090dbfb1051fc2ad021de5f490aada/internal/adc/translator/httproute.go#L378
   - Then there are two cases further:
      1. Service was of type ExternalName. In this case, we dont need the 
endpointslices and simply return the UpstreamNode with serviceport and address 
https://github.com/apache/apisix-ingress-controller/blob/476783aab6090dbfb1051fc2ad021de5f490aada/internal/adc/translator/httproute.go#L402
      2. Service is not ExternalName and in this case we use the portname and 
weight from BackendRef to translateEndpointSlice  
https://github.com/apache/apisix-ingress-controller/blob/476783aab6090dbfb1051fc2ad021de5f490aada/internal/adc/translator/httproute.go#L425
   
   
   So in conclusion, the current logic is correct and here we only need the 
serviceport as endpoint will be later resolved in another function depending on 
service type



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to