From ea0571803b4c15aafce688e9472c7f3ac27184ca Mon Sep 17 00:00:00 2001 From: johnlanni Date: Wed, 3 Sep 2025 14:55:28 +0800 Subject: [PATCH] fix ConvertBackendService --- pkg/ingress/kube/common/tool.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/ingress/kube/common/tool.go b/pkg/ingress/kube/common/tool.go index b50022137..8306adab6 100644 --- a/pkg/ingress/kube/common/tool.go +++ b/pkg/ingress/kube/common/tool.go @@ -334,9 +334,16 @@ func SplitServiceFQDN(fqdn string) (string, string, bool) { func ConvertBackendService(routeDestination *networking.HTTPRouteDestination) model.BackendService { parts := strings.Split(routeDestination.Destination.Host, ".") + var namespace, name string + if len(parts) == 2 || len(parts) > 2 && strings.HasSuffix(routeDestination.Destination.Host, "cluster.local") { + name = parts[0] + namespace = parts[1] + } else { + name = routeDestination.Destination.Host + } service := model.BackendService{ - Namespace: parts[1], - Name: parts[0], + Namespace: namespace, + Name: name, Weight: routeDestination.Weight, } if routeDestination.Destination.Port != nil {