gxthrj commented on a change in pull request #576:
URL:
https://github.com/apache/apisix-ingress-controller/pull/576#discussion_r667290987
##########
File path: pkg/kube/translation/util.go
##########
@@ -110,6 +111,46 @@ loop:
return svc.Spec.ClusterIP, svcPort, nil
}
+// getStreamServiceClusterIPAndPort is for v2beta1 streamRoute
+func (t *translator) getStreamServiceClusterIPAndPort(backend
configv2beta1.ApisixRouteStreamBackend, ns string) (string, int32, error) {
+ svc, err := t.ServiceLister.Services(ns).Get(backend.ServiceName)
+ if err != nil {
+ return "", 0, err
+ }
+ svcPort := int32(-1)
+loop:
+ for _, port := range svc.Spec.Ports {
+ switch backend.ServicePort.Type {
+ case intstr.Int:
+ if backend.ServicePort.IntVal == port.Port {
+ svcPort = port.Port
+ break loop
+ }
+ case intstr.String:
+ if backend.ServicePort.StrVal == port.Name {
+ svcPort = port.Port
+ break loop
+ }
+ }
+ }
+ if svcPort == -1 {
+ log.Errorw("ApisixRoute refers to non-existent Service port",
+ zap.String("ApisixRoute namespace", ns),
+ zap.String("port", backend.ServicePort.String()),
+ )
+ return "", 0, err
+ }
+
+ if backend.ResolveGranularity == "service" && svc.Spec.ClusterIP == "" {
Review comment:
Yep, I moved them to the line before loop, and ditto with the other two
versions.
--
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]