AlinsRan commented on code in PR #2582:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2582#discussion_r2386468919
##########
internal/adc/translator/apisixroute.go:
##########
@@ -434,9 +455,18 @@ func (t *Translator) translateStreamRule(tctx
*provider.TranslateContext, ar *ap
svc.StreamRoutes = append(svc.StreamRoutes, sr)
auNN := types.NamespacedName{Namespace: ar.GetNamespace(), Name:
part.Backend.ServiceName}
+
upstream := adc.NewDefaultUpstream()
if au, ok := tctx.Upstreams[auNN]; ok {
- upstream, _ = t.translateApisixUpstream(tctx, au)
+ service := tctx.Services[auNN]
+ if service == nil {
+ return nil, errors.Errorf("service not found,
ApisixRoute: %s, Service: %s", utils.NamespacedName(ar), auNN)
+ }
+ port, err := getPortFromService(service,
part.Backend.ServicePort)
+ if err != nil {
+ return nil, err
+ }
+ upstream, _ = t.translateApisixUpstreamForPort(tctx, au,
ptr.To(port))
Review Comment:
fixed.
##########
internal/adc/translator/apisixroute.go:
##########
@@ -434,9 +455,18 @@ func (t *Translator) translateStreamRule(tctx
*provider.TranslateContext, ar *ap
svc.StreamRoutes = append(svc.StreamRoutes, sr)
auNN := types.NamespacedName{Namespace: ar.GetNamespace(), Name:
part.Backend.ServiceName}
+
upstream := adc.NewDefaultUpstream()
if au, ok := tctx.Upstreams[auNN]; ok {
- upstream, _ = t.translateApisixUpstream(tctx, au)
+ service := tctx.Services[auNN]
+ if service == nil {
+ return nil, errors.Errorf("service not found,
ApisixRoute: %s, Service: %s", utils.NamespacedName(ar), auNN)
+ }
Review Comment:
fixed.
##########
internal/adc/translator/apisixupstream.go:
##########
@@ -33,50 +34,73 @@ import (
"github.com/apache/apisix-ingress-controller/internal/utils"
)
-func (t *Translator) translateApisixUpstream(tctx *provider.TranslateContext,
au *apiv2.ApisixUpstream) (ups *adc.Upstream, err error) {
- ups = adc.NewDefaultUpstream()
- for _, f := range []func(*apiv2.ApisixUpstream, *adc.Upstream) error{
- patchApisixUpstreamBasics,
+func (t *Translator) translateApisixUpstream(tctx *provider.TranslateContext,
au *apiv2.ApisixUpstream) (*adc.Upstream, error) {
+ return t.translateApisixUpstreamForPort(tctx, au, nil)
+}
+
+func (t *Translator) translateApisixUpstreamForPort(tctx
*provider.TranslateContext, au *apiv2.ApisixUpstream, port *int32)
(*adc.Upstream, error) {
+ log.Debugw("translating ApisixUpstream", zap.Any("apisixupstream", au),
zap.Int32p("port", port))
+
+ ups := adc.NewDefaultUpstream()
+ ups.Name = composeExternalUpstreamName(au)
+ maps.Copy(ups.Labels, au.Labels)
+
+ if err := translateApisixUpstreamConfig(tctx,
&au.Spec.ApisixUpstreamConfig, ups); err != nil {
+ return nil, err
+ }
+ if err := translateApisixUpstreamExternalNodes(tctx, au, ups); err !=
nil {
+ return nil, err
+ }
Review Comment:
fixed.
--
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]