From 2438a731d27f9e9c710a27cd1746b4f480bd9edd Mon Sep 17 00:00:00 2001 From: liaochuntao Date: Mon, 8 Jan 2024 22:40:08 +0800 Subject: [PATCH] fix:xds rule build (#1318) --- apiserver/xdsserverv3/resource/help.go | 16 ++++++++-------- apiserver/xdsserverv3/server.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apiserver/xdsserverv3/resource/help.go b/apiserver/xdsserverv3/resource/help.go index 96e2fae8a..eaf90defc 100644 --- a/apiserver/xdsserverv3/resource/help.go +++ b/apiserver/xdsserverv3/resource/help.go @@ -345,7 +345,7 @@ func BuildRateLimitDescriptors(rule *traffic_manage.Rule) ([]*route.RateLimit_Ac Value: arg.GetValue().GetValue().GetValue(), }) case apitraffic.MatchArgument_QUERY: - queryParameterValueMatch := BuildRateLimitActionQueryParameterValueMatch(descriptorKey, arg.Value) + queryParameterValueMatch := BuildRateLimitActionQueryParameterValueMatch(descriptorKey, arg) actions = append(actions, &route.RateLimit_Action{ ActionSpecifier: &route.RateLimit_Action_QueryParameterValueMatch_{ QueryParameterValueMatch: queryParameterValueMatch, @@ -392,22 +392,22 @@ func BuildRateLimitDescriptors(rule *traffic_manage.Rule) ([]*route.RateLimit_Ac } func BuildRateLimitActionQueryParameterValueMatch(key string, - value *apimodel.MatchString) *route.RateLimit_Action_QueryParameterValueMatch { + arg *apitraffic.MatchArgument) *route.RateLimit_Action_QueryParameterValueMatch { queryParameterValueMatch := &route.RateLimit_Action_QueryParameterValueMatch{ DescriptorKey: key, - DescriptorValue: value.GetValue().GetValue(), + DescriptorValue: arg.GetValue().GetValue().GetValue(), ExpectMatch: wrapperspb.Bool(true), QueryParameters: []*route.QueryParameterMatcher{}, } - switch value.GetType() { + switch arg.GetValue().GetType() { case apimodel.MatchString_EXACT: queryParameterValueMatch.QueryParameters = []*route.QueryParameterMatcher{ { - Name: key, + Name: arg.GetKey(), QueryParameterMatchSpecifier: &route.QueryParameterMatcher_StringMatch{ StringMatch: &v32.StringMatcher{ MatchPattern: &v32.StringMatcher_Exact{ - Exact: value.GetValue().GetValue(), + Exact: arg.GetValue().GetValue().GetValue(), }, }, }, @@ -416,13 +416,13 @@ func BuildRateLimitActionQueryParameterValueMatch(key string, case apimodel.MatchString_REGEX: queryParameterValueMatch.QueryParameters = []*route.QueryParameterMatcher{ { - Name: key, + Name: arg.GetKey(), QueryParameterMatchSpecifier: &route.QueryParameterMatcher_StringMatch{ StringMatch: &v32.StringMatcher{ MatchPattern: &v32.StringMatcher_SafeRegex{ SafeRegex: &v32.RegexMatcher{ EngineType: &v32.RegexMatcher_GoogleRe2{}, - Regex: value.GetValue().GetValue(), + Regex: arg.GetValue().GetValue().GetValue(), }, }, }, diff --git a/apiserver/xdsserverv3/server.go b/apiserver/xdsserverv3/server.go index 9ae925339..8429643e5 100644 --- a/apiserver/xdsserverv3/server.go +++ b/apiserver/xdsserverv3/server.go @@ -337,7 +337,7 @@ func (x *XDSServer) getRegistryInfoWithCache(ctx context.Context, } // 获取routing配置 - routerRule, err := x.namingServer.Cache().RoutingConfig().GetRouterConfig("", svc.Name, svc.Namespace) + routerRule, err := x.namingServer.Cache().RoutingConfig().GetRouterConfigV2("", svc.Name, svc.Namespace) if err != nil { log.Errorf("error sync routing for namespace(%s) service(%s), info : %s", svc.Namespace, svc.Name, err.Error())