Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:xds rule build #1318

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading