Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【enhancement】add policy event, report to backend #1171

Merged
merged 1 commit into from
Apr 8, 2023

Conversation

robotLJW
Copy link
Collaborator

@robotLJW robotLJW commented Apr 3, 2023

【修复issue】#1176

【修改内容】
Policy事件包含三件:
1.相同标签规则匹配成功: 全部实例最小可用阈值大于全部可用实例数,则同TAG优先
2.相同标签规则匹配成功:
未设置全部实例最小可用阈值,超过(大于等于)同TAG比例阈值,则同TAG优先
设置了全部实例最小可用阈值,但其小于全部TAG可用实例,超过(大于等于)同TAG比例阈值,则同TAG优先
3.相同标签规则匹配失败

【用例描述】无

【自测情况】(feign,rest,dubbo):只会上报前后两次状态不同的事件
应用:一个带gray:red的parameter且版本为1.0.1的consumer
三个provider分别是:

  1. 带group:abcd的parameter
  2. 带group:abc的parameter
  3. 版本为1.0.0

模拟请求:

curl  ip:port/router/cloud/getMetadata

场景一:policy中仅设置比例阈值为20%,同TAG优先

---
- kind: routematcher.sermant.io/tag
  description: aaa
  rules:
    - precedence: 1
      match:
        tags:
          group:
            exact: abc
        policy:
          triggerThreshold: 20
      route:
        - tags:
            gray: CONSUMER_TAG

验证:同TAG优先,一直访问到带red的下游服务
image

backend界面:同TAG优先规则匹配生效

image


场景二:policy中仅设置比例阈值为50%,非同TAG优先,随机访问ALL

---
- kind: routematcher.sermant.io/tag
  description: aaa
  rules:
    - precedence: 1
      match:
        tags:
          group:
            exact: abc
        policy:
          triggerThreshold: 50
      route:
        - tags:
            gray: CONSUMER_TAG

验证:非同TAG优先,随机访问
image

backend界面:同TAG优先规则匹配失效
image


场景三:policy中设置比例阈值为20%和最小可用实例阈值4,同TAG优先

---
- kind: routematcher.sermant.io/tag
  description: aaa
  rules:
    - precedence: 1
      match:
        tags:
          group:
            exact: abc
        policy:
          triggerThreshold: 20
          minAllInstances: 4
      route:
        - tags:
            gray: CONSUMER_TAG

验证:同TAG优先,一直访问到带red的下游服务
image

backend界面:同TAG优先规则匹配生效
image


场景四:policy中设置比例阈值为20%和最小可用实例阈值1,同TAG优先

---
- kind: routematcher.sermant.io/tag
  description: aaa
  rules:
    - precedence: 1
      match:
        tags:
          group:
            exact: abc
        policy:
          triggerThreshold: 20
          minAllInstances: 1
      route:
        - tags:
            gray: CONSUMER_TAG

验证:同TAG优先,一直访问到带red的下游服务
image

backend界面:同TAG优先规则匹配生效
image


场景五:policy中设置比例阈值为50%和最小可用实例阈值1,非同TAG优先,随机访问ALL

---
- kind: routematcher.sermant.io/tag
  description: aaa
  rules:
    - precedence: 1
      match:
        tags:
          group:
            exact: abc
        policy:
          triggerThreshold: 50
          minAllInstances: 1
      route:
        - tags:
            gray: CONSUMER_TAG

验证:非同TAG优先,随机访问ALL
image
backend界面:同TAG优先规则匹配失效
image

【影响范围】是需要更新一些文档(router手册)

@robotLJW robotLJW force-pushed the develop branch 3 times, most recently from 1d6306d to 7548632 Compare April 3, 2023 13:41
@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Patch coverage: 68.96% and project coverage change: +0.58 🎉

Comparison is base (e6167c0) 41.57% compared to head (bfc68e1) 42.16%.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1171      +/-   ##
=============================================
+ Coverage      41.57%   42.16%   +0.58%     
- Complexity      3184     3226      +42     
=============================================
  Files            810      812       +2     
  Lines          17826    17917      +91     
  Branches        1938     1948      +10     
=============================================
+ Hits            7411     7554     +143     
+ Misses          9475     9415      -60     
- Partials         940      948       +8     
Flag Coverage Δ
unittests 42.16% <68.96%> (+0.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ant/router/common/event/RouterEventDefinition.java 0.00% <0.00%> (ø)
...mant/router/common/event/RouterEventCollector.java 26.19% <12.50%> (+26.19%) ⬆️
.../sermant/router/config/utils/PolicyEventUtils.java 92.30% <92.30%> (ø)
...cloud/sermant/router/common/event/PolicyEvent.java 100.00% <100.00%> (ø)
...t/router/config/strategy/AbstractRuleStrategy.java 89.28% <100.00%> (+3.91%) ⬆️

... and 28 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@robotLJW robotLJW force-pushed the develop branch 4 times, most recently from 62847f3 to b340639 Compare April 4, 2023 14:22
@robotLJW robotLJW added the kind/enhancement Issues or PRs releated to sermant enhancement label Apr 4, 2023
@robotLJW robotLJW force-pushed the develop branch 5 times, most recently from f553868 to abd3495 Compare April 6, 2023 03:41
provenceee
provenceee previously approved these changes Apr 6, 2023
@robotLJW robotLJW force-pushed the develop branch 3 times, most recently from dd00c41 to 47a8c46 Compare April 7, 2023 07:31
@luanwenfei-venus luanwenfei-venus merged commit 0b1568a into sermant-io:develop Apr 8, 2023
@robotLJW robotLJW added this to the v1.1.0 milestone Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Issues or PRs releated to sermant enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants