Open
Conversation
- 在 META-INF/services 中注册新的标签表达式灰度规则实现类 - 为 ConfigForm 新增 labels 和 grayType 字段及其 getter/setter 方法 - 集成 ConnLabelsUtils 工具类用于解析原始标签字符串为应用标签映射 - 实现通用灰度发布逻辑,支持基于标签表达式的灰度配置发布 - 添加标签表达式解析功能,支持 AND 和 OR 逻辑操作符 - 实现标签匹配验证机制,确保灰度规则正确生效 - 完善单元测试覆盖新功能的各种使用场景
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
Contributor
Author
|
@KomachiSion 哈喽 有空麻烦看看这个pr呗 谢谢啦😊 |
Collaborator
|
Why add this feature? |
Contributor
Author
|
因为现有灰度能力已经有规则基础设施,但规则类型主要还是 beta/tag 这类固定模式,扩展性有限。我这次主要是想在兼容原有能力的前提下,补齐基于 labels 的通用匹配能力,支持更灵活的灰度场景,同时也让后续新增灰度规则类型更容易复用现有框架。 |
Collaborator
|
@1lck 先提一个issue讨论一下吧 |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please do not create a Pull Request without creating an issue first.
What is the purpose of the change
当前 Nacos 配置中心的灰度能力主要基于 beta/tag 等内置规则,规则类型相对固定,在更复杂的灰度分流场景下扩展性有限。
本次修改在兼容既有 beta/tag 灰度能力的基础上,补充了基于 labels 表达式的通用灰度规则能力,使配置发布与查询链路可以根据请求标签信息匹配灰度配置,支持更灵活的灰度场景。
当前暂未找到完全对应的现有 issue,因此先提交 PR 说明实现方案与验证结果;如有需要,我可以进一步补充对应 issue 并关联。
Brief changelog
LabelExpressionGrayRule并通过 SPI 注册规则实现&&和||ConfigForm中新增labels和grayType字段ConnLabelsUtils将原始标签字符串解析为应用标签映射ConfigOperationService中补充通用灰度发布逻辑labels,参与灰度规则匹配Verifying this change
单元测试:
./mvnw -pl config -Dtest=LabelExpressionGrayRuleTest,ConfigOpenApiControllerTest,ConfigOperationServiceTest test本地联调验证:
grayType=label_exprgrayRuleExp=region == 'hz' && env == 'prod'labels查询配置,确认返回正式配置labels=region=hz,env=prod查询配置,确认返回灰度配置联调结果:
labels时返回mode: formalmode: grayFollow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean package apache-rat:check spotbugs:check -DskipTeststo make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.