You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:47:02 UTC

[GitHub] [apisix-ingress-controller] gxthrj commented on a change in pull request #544: fix: use not strictly translation when remote ApisixRoute

gxthrj commented on a change in pull request #544:
URL: https://github.com/apache/apisix-ingress-controller/pull/544#discussion_r649823526



##########
File path: pkg/kube/translation/apisix_route.go
##########
@@ -304,6 +346,24 @@ func (t *translator) translateRouteMatchExprs(nginxVars []configv2alpha1.ApisixR
 	return vars, nil
 }
 
+// translateTCPRouteNotStrictly is not strictly translation, only generate ID and Name for delete Event.
+func (t *translator) translateTCPRouteNotStrictly(ctx *TranslateContext, ar *configv2alpha1.ApisixRoute) error {
+	for _, part := range ar.Spec.TCP {
+		backend := &part.Backend
+		sr := apisixv1.NewDefaultStreamRoute()
+		name := apisixv1.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name)
+		sr.ID = id.GenID(name)
+		sr.ServerPort = part.Match.IngressPort
+		ups, err := t.translateUpstreamNotStrictly(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal)
+		if err != nil {
+			return err
+		}
+		sr.Upstream = ups
+		ctx.addStreamRoute(sr)

Review comment:
       ref to:https://github.com/apache/apisix-ingress-controller/blob/master/pkg/kube/translation/apisix_route.go#L333
   Are you sure need to add `ups` to `ctx`?

##########
File path: pkg/kube/translation/apisix_route.go
##########
@@ -304,6 +346,24 @@ func (t *translator) translateRouteMatchExprs(nginxVars []configv2alpha1.ApisixR
 	return vars, nil
 }
 
+// translateTCPRouteNotStrictly is not strictly translation, only generate ID and Name for delete Event.
+func (t *translator) translateTCPRouteNotStrictly(ctx *TranslateContext, ar *configv2alpha1.ApisixRoute) error {
+	for _, part := range ar.Spec.TCP {
+		backend := &part.Backend
+		sr := apisixv1.NewDefaultStreamRoute()
+		name := apisixv1.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name)
+		sr.ID = id.GenID(name)
+		sr.ServerPort = part.Match.IngressPort
+		ups, err := t.translateUpstreamNotStrictly(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal)
+		if err != nil {
+			return err
+		}
+		sr.Upstream = ups
+		ctx.addStreamRoute(sr)

Review comment:
       Fixed.

##########
File path: pkg/kube/translation/apisix_route.go
##########
@@ -329,8 +389,9 @@ func (t *translator) translateTCPRoute(ctx *TranslateContext, ar *configv2alpha1
 		if err != nil {
 			return err
 		}
-		sr.Upstream = ups
+		sr.UpstreamId = ups.ID
 		ctx.addStreamRoute(sr)
+		ctx.addUpstream(ups)

Review comment:
       Done.

##########
File path: test/e2e/scaffold/k8s.go
##########
@@ -29,11 +28,12 @@ import (
 	"github.com/stretchr/testify/assert"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/util/intstr"
 	"k8s.io/apimachinery/pkg/util/wait"
 )
 
 type counter struct {
-	Count string `json:"count"`
+	Count intstr.IntOrString `json:"count"`

Review comment:
       This can not be work. 
   Done. Customize the `intOrString` 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.

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