支持规则同步到nacos#3635
Conversation
|
zhangyunlong seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
BitDive Runtime Review - PR #3635PR: #3635 SummaryThis PR rewires all five rule-management controllers (Flow V2, Degrade, ParamFlow, Authority, System) from The dominant symptom is silent data loss. The Nacos server address is hardcoded to Beyond the cross-cutting data-loss issue, each controller has its own behavior change worth flagging:
Latency on every endpoint jumps 14×–450× (e.g. Fix before merge:
Runtime Verification Matrix
* Stable relative to the other controllers — the same Nacos-side silent-data-loss pattern still applies. How to read BitDive evidenceBehavior Δ in the matrix and the red/green
GitHub strips Review scope and validation coverage
Out of scope for runtime review: CI/CD assets; frontend Change #1 - FlowControllerV2 silent bean hijackThe V2 flow controller keeps the same Behavior contract# GET /v2/flow/rules?app=sentinel-dashboard — runtime contract
- HTTP 200 OK {success:true, data:[]}
+ HTTP 200 OK {success:true, data:[]} (silent — Nacos unreachable)
- bean: @Component('flowRuleDefaultProvider') = FlowRuleApiProvider
+ bean: @Component('flowRuleDefaultProvider') = FlowRuleNacosProvider
- call tree: FlowRuleApiProvider.getRules → SentinelApiClient.fetchFlowRuleOfMachine → fetchRules → fetchItems → fetchItemsAsync → executeCommand (6 nested, 14 child calls)
+ call tree: FlowRuleNacosProvider.getRules → ConfigService.getConfig (3s timeout, empty data, 2 child calls)
- write: InMemoryRuleRepositoryAdapter.saveAll([])
+ write: InMemoryRuleRepositoryAdapter.saveAll([]) (retained — empty list both sides)
- data source: Sentinel client library over HTTP (172.17.0.2:8719)
+ data source: Nacos ConfigService (private LAN IP 192.168.234.59:8848)
- time: 221ms
+ time: 3070ms (14x slowdown)
# first divergence: FlowRuleNacosProvider.getRules()
- apiQueryMachineRules → FlowRuleApiProvider.getRules → SentinelApiClient chain
+ apiQueryMachineRules → FlowRuleNacosProvider.getRules → ConfigService.getConfig (3s timeout → empty)Scenario matrix
Trace evidence
Contract delta
Key trace deltaFirst meaningful divergence:
Change #2 - DegradeController API contract breakThe degrade controller query method drops Behavior contract# GET /degrade/rules.json?app=sentinel-dashboard&ip=127.0.0.1&port=8719 — runtime contract
- HTTP 200 OK {success:true, data:[]}
+ HTTP 200 OK {success:true, data:[]} (silent — Nacos unreachable)
- method args: [app='sentinel-dashboard', ip='172.17.0.2', port=8719] (3 args)
+ method args: [app='sentinel-dashboard'] (1 arg — ip/port dropped from signature)
- validation: AppManagement.isValidMachineOfApp(app, ip, port)
+ validation: REMOVED (no ip/port to validate)
- call tree: SentinelApiClient.fetchDegradeRuleOfMachine → executeCommand (direct HTTP)
+ call tree: DegradeRuleNacosProvider.getRules → ConfigService.getConfig (3s timeout)
- write: InMemoryRuleRepositoryAdapter.saveAll([])
+ write: InMemoryRuleRepositoryAdapter.saveAll([]) (retained under different parent path)
- mutation: publishRules returns boolean
+ mutation: publishRules throws Exception (code-only)
- time: 8.8ms
+ time: 3010ms (342x slowdown)
# first divergence: DegradeRuleNacosProvider.getRules()Scenario matrix
Trace evidence
Contract delta
Key trace deltaFirst meaningful divergence:
Change #3 - ParamFlowRuleController major simplification + write addedThe most aggressive refactor: method signature drops Behavior contract# GET /paramFlow/rules?app=sentinel-dashboard&ip=127.0.0.1&port=8719 — runtime contract
- HTTP 200 OK {success:true, data:[]}
+ HTTP 200 OK {success:true, data:[]} (silent — Nacos unreachable)
- method args: [app, ip, port] (3 args)
+ method args: [app] (1 arg — ip/port dropped)
- pre-call: checkIfSupported (Sentinel client version check)
+ pre-call: REMOVED
- async: CompletableFuture.supplyAsync → SentinelApiClient chain
+ sync: ParamFlowRuleNacosProvider.getRules → ConfigService.getConfig (blocking 3s)
- write: no saveAll on query path
+ write: InMemoryRuleRepositoryAdapter.saveAll([]) ADDED
- call tree: 11 child calls
+ call tree: 2 child calls
- time: 11.7ms
+ time: 3009ms (257x slowdown)
# first divergence: InMemoryRuleRepositoryAdapter.saveAll() added in AFTERScenario matrix
Trace evidence
Contract delta
Key trace deltaFirst meaningful divergence:
Change #4 - AuthorityRuleController saveAll removedThe only controller where Behavior contract# GET /authority/rules?app=sentinel-dashboard&ip=127.0.0.1&port=8719 — runtime contract
- HTTP 200 OK {success:true, data:[]}
+ HTTP 200 OK {success:true, data:[]} (silent — Nacos unreachable)
- method args: [app, ip, port] (3 args — signature UNCHANGED, validation retained)
+ method args: [app, ip, port] (3 args — signature UNCHANGED)
- validation: checkBasicParams → isValidMachineOfApp (retained)
+ validation: checkBasicParams → isValidMachineOfApp (retained)
- write: InMemoryRuleRepositoryAdapter.saveAll([]) called
+ write: saveAll REMOVED from query path
- call tree: SentinelApiClient.fetchAuthorityRulesOfMachine chain (14 child calls)
+ call tree: AuthorityRuleNacosProvider.getRules (4 child calls)
- time: 6.68ms
+ time: 3013ms (450x slowdown)
# first divergence: AppManagement.getDetailApp() (environmental drift — hostname/version/heartbeat)
# structural change: AuthorityRuleNacosProvider.getRules replacing SentinelApiClient chainBaseline note: The first divergence flagged by the trace comparison is Scenario matrix
Trace evidence
Contract delta
Key trace deltaFirst code divergence (after environmental drift):
Change #5 - SystemController cleanest migrationThe best-implemented migration of the five: Behavior contract# GET /system/rules.json?app=sentinel-dashboard&ip=127.0.0.1&port=8719 — runtime contract
- HTTP 200 OK {success:true, data:[]}
+ HTTP 200 OK {success:true, data:[]} (silent — Nacos unreachable)
- method args: [app, ip, port] (signature UNCHANGED)
+ method args: [app, ip, port] (signature UNCHANGED)
- validation: checkBasicParams → isValidMachineOfApp (retained)
+ validation: same (retained)
- provider: SentinelApiClient.fetchSystemRuleOfMachine
+ provider: SystemRuleNacosProvider.getRules → ConfigService.getConfig
- post-process: sets ip/port on each returned rule entity (code-only)
+ post-process: same code path (code-only — data=[] means no entities post-processed at runtime)
- write: InMemoryRuleRepositoryAdapter.saveAll([])
+ write: same (retained)
- time: 8.5ms
+ time: 3011ms (354x slowdown)
# first divergence: AppManagement.getDetailApp() (environmental drift — hostname/version/heartbeat)
# structural change: SystemRuleNacosProvider.getRules replacing SentinelApiClient chainScenario matrix
Trace evidence
Contract delta
Key trace deltaFirst code divergence (after environmental drift):
Follow-Ups
RecommendationRequest changes. The Nacos integration pattern is sound and |
支持规则同步到nacos。
包括:流控,熔断,热点,系统,授权