diff --git a/plugin/servicerouter/rulebase/base.go b/plugin/servicerouter/rulebase/base.go index b9314061..6ebbb321 100644 --- a/plugin/servicerouter/rulebase/base.go +++ b/plugin/servicerouter/rulebase/base.go @@ -359,6 +359,10 @@ func (g *RuleBasedInstancesFilter) matchDstMetadata(routeInfo *servicerouter.Rou // 首先如果元数据的value无法获取,直接匹配失败 return nil, false, "", nil } + // 全匹配类型直接返回全量实例 + if ruleMetaValueStr == matchAll && ruleMetaValue.ValueType == apimodel.MatchString_TEXT { + return cls, true, "", nil + } metaValues := svcCache.GetInstanceMetaValues(cls.Location, ruleMetaKey) if len(metaValues) == 0 { // 不匹配 @@ -401,9 +405,6 @@ func (g *RuleBasedInstancesFilter) matchDstMetadata(routeInfo *servicerouter.Rou if !validateInMetadata(ruleMetaKey, ruleMetaValue, ruleMetaValueStr, inCluster.Metadata, nil) { return nil, false, "", nil } - if ruleMetaValueStr == matchAll && ruleMetaValue.ValueType == apimodel.MatchString_TEXT { - return cls, true, "", nil - } if composedValue, ok := metaValues[ruleMetaValueStr]; ok { if cls.RuleAddMetadata(ruleMetaKey, ruleMetaValueStr, composedValue) { metaChanged = true