Skip to content

Commit

Permalink
fix:xds rule build (#1318)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun committed Jan 8, 2024
1 parent 2ce2f5a commit 2438a73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions apiserver/xdsserverv3/resource/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
},
},
},
Expand All @@ -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(),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion apiserver/xdsserverv3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 2438a73

Please sign in to comment.