Frun1na opened a new pull request, #6816:
URL: https://github.com/apache/rocketmq-dashboard/pull/6816

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6814
   
   ### Brief Description
   
   A NameServer registry row on the Cluster page resolved its live cluster with 
`resolveNameserverRegistryCluster` (`web/src/pages/cluster/index.tsx:377-390`), 
whose last branch matched `cluster.nsClusterName === entry.name`. 
`nsClusterName` is not a link to the registry entry: 
`ClusterService.probeRegistryEntry` 
(`server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java:107-121`)
 stamps every probe with `name = entry.getName()`, `nsClusterName = <broker 
cluster name discovered behind that entry's NameServer>`, `endpoint = 
entry.getNamesrvAddr()`, and `RegistryProbeRunner.probeAll` concatenates the 
probes in registry id order. Two entries whose NameServers both host a broker 
cluster with the same name — `DefaultCluster` is the RocketMQ default — 
therefore made the younger row match the older entry's cluster first, and its 
"NameServer 配置差异" action asked for the drift report of the other entry's 
NameServer (`getNameServerConfigDiff(cluster.id, reso
 lveOwningInstanceId(cluster))`, `:392-404`).
   
   The lookup now accepts only clusters the entry owns: the probe endpoint / 
nameserver address (both derived from the row's `namesrvAddr`) or the entry 
name the probe carries (`name`). The action stays disabled for an entry whose 
own NameServer was not probed successfully, instead of comparing whichever 
entry happens to serve a broker cluster with the same name. The user-visible 
change is that the diff dialog now reports the NameServer address shown in the 
row.
   
   ### Other consumers
   
   `nsClusterName` is a display/search label everywhere else; this lookup was 
its only identity use.
   
   - `web/src/pages/cluster/index.tsx:377-390` — the registry-row lookup fixed 
here (`nsClusterName` branch removed).
   - `web/src/pages/cluster/index.tsx:917` and `:1043` — diff dialog titles 
label the selected cluster with `nsClusterName`; unchanged, correct as a title.
   - `web/src/pages/cluster/index.tsx:1224` (broker table search) and 
`:1240-1244`, `:1701-1704` (broker/proxy columns) — substring search and 
display only; unchanged.
   - `web/src/pages/cluster/clients.tsx:284` — the clients-page cluster filter 
offers `nsClusterName` values as filter options; two clusters sharing a broker 
cluster name intentionally collapse into one option, since the filter matches 
the client's reported cluster name; unchanged.
   - `web/src/pages/studio/BrokerCluster.tsx:135` — falls back through 
`nsClusterName || name || id` for a row label; unchanged.
   - `web/src/services/clusterService.ts:89` — mock `clusterName` fallback (`?? 
'DefaultCluster'`) for the probe result card; unchanged.
   
   ### How Did You Test This Change?
   
   ```
   $ wb test --filter src/pages/cluster/__tests__/ClusterPage.test.tsx   # from 
the worktree
   ── web (web)
   ✓    2.3s  npx eslint src/pages/cluster/__tests__/ClusterPage.test.tsx 
src/pages/cluster/index.tsx
   ✓    0.8s  npx prettier --check 
src/pages/cluster/__tests__/ClusterPage.test.tsx src/pages/cluster/index.tsx
   ✓   43.2s  npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx 
--maxWorkers=1 --fileParallelism=false
   ✓    4.0s  npx tsc -b
   
   $ wb test   # every check the change maps to, no filter
   ✓  npx eslint …      ✓  npx prettier --check …      ✓  npx vitest related …  
    ✓  npx tsc -b
   
    Test Files  1 passed (1)
         Tests  38 passed (38)
   ```
   
   The new test fails without the fix:
   
   ```
   FAIL src/pages/cluster/__tests__/ClusterPage.test.tsx > Cluster page > 
scopes a registry row to its own NameServer when another entry serves the same 
broker cluster name
   AssertionError: expected "vi.fn()" to be called with arguments: [ 
'DefaultCluster', 'instance-prod' ]
   
   Received:
   
     1st vi.fn() call:
   
     [
       "DefaultCluster",
   -   "instance-prod",
   +   "instance-edge",
     ]
   
    Test Files  1 failed (1)
         Tests  1 failed | 37 passed (38)
   ```
   
   `instance-edge` owns the other entry's NameServer (`edge-ns:9876`), which is 
the address the server would have collected the config from; the fixed lookup 
asks for `instance-prod`, the instance of the row's own `prod-ns:9876`. The 
test also pins the dialog content: it lists `prod-ns:9876` and no longer 
`edge-ns:9876`.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`feat:` / `fix:` / 
`refactor:` / `chore:` / `docs:` / `perf:`)
   - [x] Tests added or updated for non-trivial changes, test methods named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks)
   - [ ] New source files carry the ASF license header
   - [ ] Documentation touched where behaviour changed (README / `docs/` / 
in-app help)
   


-- 
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