dspo commented on code in PR #2451:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2451#discussion_r2184269082
##########
internal/provider/adc/translator/httproute.go:
##########
@@ -312,11 +315,19 @@ func (t *Translator) translateEndpointSlice(portName
*string, weight int, endpoi
return nodes
}
-func (t *Translator) TranslateBackendRef(tctx *provider.TranslateContext, ref
gatewayv1.BackendRef) (adctypes.UpstreamNodes, error) {
- return t.translateBackendRef(tctx, ref)
+func DefaultEndpointFilter(endpoint *discoveryv1.Endpoint) bool {
+ if endpoint.Conditions.Ready != nil && !*endpoint.Conditions.Ready {
+ log.Debugw("skip not ready endpoint", zap.Any("endpoint",
endpoint))
+ return false
+ }
+ return true
+}
+
+func (t *Translator) TranslateBackendRefWithFilter(tctx
*provider.TranslateContext, ref gatewayv1.BackendRef, endpointFilter
func(*discoveryv1.Endpoint) bool) (adctypes.UpstreamNodes, error) {
+ return t.translateBackendRef(tctx, ref, endpointFilter)
}
-func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref
gatewayv1.BackendRef) (adctypes.UpstreamNodes, error) {
+func (t *Translator) translateBackendRef(tctx *provider.TranslateContext, ref
gatewayv1.BackendRef, endpointFilter func(*discoveryv1.Endpoint) bool)
(adctypes.UpstreamNodes, error) {
Review Comment:
These two functions are exactly the same. Can they be combined into one
function?
##########
internal/provider/adc/translator/httproute.go:
##########
@@ -283,7 +283,7 @@ func (t *Translator) fillHTTPRoutePolicies(routes
[]*adctypes.Route, policies []
}
}
-func (t *Translator) translateEndpointSlice(portName *string, weight int,
endpointSlices []discoveryv1.EndpointSlice) adctypes.UpstreamNodes {
+func (t *Translator) translateEndpointSlice(portName *string, weight int,
endpointSlices []discoveryv1.EndpointSlice, endpointFilter
func(*discoveryv1.Endpoint) bool) adctypes.UpstreamNodes {
Review Comment:
This method seems to cover the functionality of
`translateEndpointSliceForIngress`. It seems that
`translateEndpointSliceForIngress` can be removed or called
`translateEndpointSlice ` in it.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]