Skip to content

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
polarismesh:mainfrom
fuyuwei01:polaris-lane-fix
Open

fix: newer lane rules take precedence over older ones when priority is equal in TSF mode#711
fuyuwei01 wants to merge 1 commit into
polarismesh:mainfrom
fuyuwei01:polaris-lane-fix

Conversation

@fuyuwei01

Copy link
Copy Markdown
Member

问题描述

泳道路由在规则排序时,三级排序为:流量入口 → 优先级 → 创建时间。当前 ctime 比较使用升序,导致同优先级时旧规则优先匹配。

在 TSF 场景下,期望行为是新规则优先(即后创建的规则覆盖旧规则)。

修改内容

LaneRuleContainer 构造函数中,排序前先检测当前 groups 是否为 TSF 模式(通过 group.getName() == "tsf" 判断,与 LaneRouter#checkServiceInLane 的判断逻辑一致):

  • TSF 场景ctime 降序 → 新规则优先
  • 非 TSF 场景ctime 升序 → 旧规则优先(维持原有行为)

变更文件

  • polaris-plugins/polaris-plugins-router/router-lane/src/main/java/com/tencent/polaris/plugins/router/lane/LaneRuleContainer.java

🤖 Generated with Claude Code

在 TSF 模式下,同优先级的泳道规则按创建时间降序排列,使新创建的规则优先匹配;
非 TSF 场景维持原有行为(旧规则优先)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fuyuwei01 fuyuwei01 changed the title fix: TSF场景下同优先级泳道规则以新规则优先 fix: newer lane rules take precedence over older ones when priority is equal in TSF mode Apr 28, 2026
@codecov

codecov Bot commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.58%. Comparing base (b3df955) to head (8418ed9).
⚠️ Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant