unbridled-41 opened a new pull request, #4660:
URL: https://github.com/apache/rocketmq-dashboard/pull/4660

   Fixes #4656.
   
   ## Problem / Evidence
   
   `InstanceService.importCloudInstances` collects region and per-instance 
failures and reports them in `CloudImportResultVO` (the API response and the 
web page correctly show a partial-failure warning), but the operation-audit row 
for the whole import is always recorded as `SUCCESS`:
   
   - `InstanceService.finishCloudImport` calls 
`recordAudit("IMPORT_CLOUD_INSTANCES", ...)` with the failure counts embedded 
in the detail text only (`InstanceService.java:356-358`);
   - the private `recordAudit` helper hardcoded `"SUCCESS"` as the result 
(`InstanceService.java:833-841`) and had no way to pass anything else;
   - the existing regression 
`importCloudInstancesShouldContinueAfterUnexpectedRegionFailureTest` pins the 
wrong behavior: an import with `failed=1` asserting `eq("SUCCESS")` 
(`InstanceServiceTest.java:1416-1418` on master).
   
   So an import whose catalog provider is missing, whose `listRegions` throws 
(invalid credential), or in which every region/instance fails produces an audit 
timeline entry and summary counts that say the operation succeeded.
   
   Red regressions (two new tests):
   1. `importCloudInstancesShouldContinueAfterUnexpectedRegionFailureTest` 
(updated expectation): 1 imported + 1 failed must audit `PARTIAL` — on master 
it failed with the recorded result `SUCCESS`.
   2. `importCloudInstancesShouldAuditAFullyFailedImportAsFailedTest` (new): 
`listRegions` throwing with zero imports must audit `FAILED` — on master it 
failed with `SUCCESS`.
   
   ## Root cause / Fix
   
   The import flow grew a proper failure model (failure counts, bounded failure 
details, partial-failure UI) but never carried the outcome into the audit call, 
whose helper predated it.
   
   Fix:
   - `recordAudit` gains a `result` parameter; the create/update/delete call 
sites pass their existing `"SUCCESS"` explicitly;
   - `finishCloudImport` grades the outcome with the shared audit vocabulary — 
`SUCCESS` when nothing failed, `PARTIAL` when some instances imported and 
failures occurred, `FAILED` when failures occurred and nothing was imported — 
mirroring the DLQ resend outcome classification 
(`RocketMQDLQProvider.classifyOutcome`).
   
   ## Priority & scoring
   
   PRIORITY = 影响 28(审计时间线/汇总把完全失败的导入记为成功,操作审计的可信面受损)+ 波及 10(import-cloud 
单一操作,但审计 summary 是共享读面)+ 可复现 20(确定性,无效凭据即触发)+ 维护价值 16(与 #4608/#4607 
同族,维护者已接受同类修复)= **74**。FIX_CONFIDENCE = **88**(分级规则与既有 DLQ 分类同构,行为全部可由 Mockito 
断言表达)。
   
   ## Tests
   
   - Two red regressions (see above):
     - Red on master: both failed with `expected "PARTIAL"/"FAILED" but was 
"SUCCESS"`.
     - Green after the fix.
   - Module: `mvn -o -Dtest='InstanceServiceTest' test` → `Tests run: 84, 
Failures: 0, Errors: 0` (82 pre-existing + 2 changed/new here).
   - Full backend suite (this branch): `SPRING_PROFILES_ACTIVE=dev mvn -o test` 
→ `Tests run: 2415, Failures: 0, Errors: 0, Skipped: 0`, `BUILD SUCCESS` 
(pristine master on this machine: 2414 passing + 1 new test here = 2415).
   - Checkstyle: `mvn -o checkstyle:check` → clean.
   - Backend package: `mvn -o -DskipTests package` → `BUILD SUCCESS`, 
`target/rocketmq-studio-1.0.0.jar` produced.
   - Frontend untouched on this branch (build verified: `npm run build` → `✓ 
built in 11.06s`).
   
   ## Risk
   
   Low. Only the `result` column of `IMPORT_CLOUD_INSTANCES` audit rows changes 
for imports that had failures; clean imports keep `SUCCESS`, and the 
create/update/delete audits keep their previous result by passing it 
explicitly. The API response shape, the web import dialog, and the 
failure-detail collection are untouched.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to