Alanxtl commented on code in PR #3660:
URL: https://github.com/apache/dubbo-go/pull/3660#discussion_r4023426168
##########
config_center/parser/configuration_parser.go:
##########
@@ -82,16 +82,19 @@ type ConditionMatch struct {
}
func (c *ConditionMatch) IsMatch(host string, url *common.URL) bool {
- if !c.Address.IsMatch(host) {
+ if c == nil {
+ return true
+ }
+ if c.Address != nil && !c.Address.IsMatch(host) {
return false
}
- if !c.ProviderAddress.IsMatch(url.Location) {
+ if c.ProviderAddress != nil && !c.ProviderAddress.IsMatch(url.Location)
{
return false
}
- if !c.Service.IsMatch(url.ServiceKey()) {
+ if c.Service != nil && !c.Service.IsMatch(url.ServiceKey()) {
return false
}
- if !c.App.IsMatch(url.GetParam(constant.ApplicationKey, "")) {
+ if c.App != nil && !c.App.IsMatch(url.GetParam(constant.ApplicationKey,
"")) {
return false
}
Review Comment:
这里使用的是 `yaml:"app"`,但官方 v3 配置格式字段是
`application`。[[官方文档](https://dubbo.apache.org/en/overview/what/core-features/traffic/configuration-rule/)](https://dubbo.apache.org/en/overview/what/core-features/traffic/configuration-rule/)明确使用
`match.application`。
YAML 中的 `application` 会被静默忽略;而本 PR 又把 nil matcher 当成“不限制”,所以限定 `app-a`
的规则会错误地应用到 `app-b`。建议兼容/改为 `yaml:"application"`,并增加 parser → configurator
的不匹配回归测试。
补充:`config-center.configVersion` 旧键兼容逻辑已在最新提交中处理。`go test ./...`
全量通过,但上述两个负向场景当前测试未覆盖。
##########
config_center/configurator/override.go:
##########
@@ -55,8 +55,11 @@ func (c *overrideConfigurator) Configure(url *common.URL) {
return
}
- // branch for version 2.7.x
- apiVersion := c.configuratorUrl.GetParam(constant.ConfigVersionKey, "")
+ // Prefer the rule-level key for versioned rules (2.7.x and v3), while
retaining the legacy key as a fallback.
+ apiVersion := c.configuratorUrl.GetParam(constant.RuleConfigVersionKey,
"")
+ if len(apiVersion) == 0 {
+ apiVersion =
c.configuratorUrl.GetParam(constant.ConfigVersionKey, "")
+ }
if len(apiVersion) != 0 {
var host string
currentSide := url.GetParam(constant.SideKey, "")
Review Comment:
`currentSide != configuratorSide` 时只是让 `host` 为空,但仍继续执行
`configureIfMatchV3`。空 `match` 会返回 true,导致 `side: consumer` 的规则也被应用到 provider
URL。
复现:`side=consumer&match={}` 的 v3 规则配置 provider,`loadbalance` 仍会被改成规则值。应在
side 不匹配时直接返回,并补充 consumer/provider 反向场景测试。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]