fix: newer lane rules take precedence over older ones when priority is equal in TSF mode#711
Open
fuyuwei01 wants to merge 1 commit into
Open
fix: newer lane rules take precedence over older ones when priority is equal in TSF mode#711fuyuwei01 wants to merge 1 commit into
fuyuwei01 wants to merge 1 commit into
Conversation
在 TSF 模式下,同优先级的泳道规则按创建时间降序排列,使新创建的规则优先匹配; 非 TSF 场景维持原有行为(旧规则优先)。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #711 +/- ##
============================================
- Coverage 22.04% 21.58% -0.46%
- Complexity 1204 1215 +11
============================================
Files 413 417 +4
Lines 17191 17649 +458
Branches 2222 2280 +58
============================================
+ Hits 3789 3810 +21
- Misses 12973 13407 +434
- Partials 429 432 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
问题描述
泳道路由在规则排序时,三级排序为:流量入口 → 优先级 → 创建时间。当前
ctime比较使用升序,导致同优先级时旧规则优先匹配。在 TSF 场景下,期望行为是新规则优先(即后创建的规则覆盖旧规则)。
修改内容
在
LaneRuleContainer构造函数中,排序前先检测当前groups是否为 TSF 模式(通过group.getName() == "tsf"判断,与LaneRouter#checkServiceInLane的判断逻辑一致):ctime降序 → 新规则优先ctime升序 → 旧规则优先(维持原有行为)变更文件
polaris-plugins/polaris-plugins-router/router-lane/src/main/java/com/tencent/polaris/plugins/router/lane/LaneRuleContainer.java🤖 Generated with Claude Code