Frun1na opened a new issue, #6814:
URL: https://github.com/apache/rocketmq-dashboard/issues/6814

   ### Before Creating the Bug Report
   
   - [x] I have searched the [open 
issues](https://github.com/apache/rocketmq-dashboard/issues) of this repository 
and believe that this is not a duplicate.
   - [x] This is a defect in RocketMQ Studio, not a usage question and not a 
defect in another Apache RocketMQ repository.
   - [x] I can reproduce this on the current `rocketmq-studio` branch, or I 
have stated the exact version I am running below.
   
   ### Studio Version
   
   branch: rocketmq-studio
   git commit id: a92c2314 (reproduced by a unit test against that commit)
   deployed as: built from source
   
   ### Runtime Environment
   
   OS: Ubuntu on WSL2
   MySQL: not applicable — the defect is in the web console (reproduced with a 
stubbed cluster service)
   browser: not applicable — reproduced by a unit test
   
   ### Connected RocketMQ Cluster
   
   RocketMQ version: not applicable — reproduced with a stubbed provider in a 
unit test
   access mode: direct to NameServer (the NameServer management tab probes the 
registered addresses)
   deployment: not applicable
   
   ### Describe the Bug
   
   The NameServer management tab resolves every registry row to one of the live 
clusters probed from `/api/clusters/registry` with 
`resolveNameserverRegistryCluster` (`web/src/pages/cluster/index.tsx:377-390`). 
Its last branch matches on `cluster.nsClusterName === entry.name`, but 
`nsClusterName` is not an ownership link. The server builds registry clusters 
in `ClusterService.probeRegistryEntry` 
(`server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterService.java:107-121`)
 as `name = entry.getName()`, `nsClusterName = <broker cluster name discovered 
behind the probed NameServer>`, `endpoint = entry.getNamesrvAddr()`, and 
`RegistryProbeRunner.probeAll` concatenates the per-entry probes in registry id 
order (`:76-85`). When two entries are backed by NameServers that both serve a 
broker cluster with the same name — `DefaultCluster` is the out-of-the-box 
RocketMQ name — the younger entry's row matches the older entry's cluster 
first, because `find` returns the first c
 luster for which any branch holds. The row's "NameServer 配置差异" (NameServer 
config diff) action then requests the drift report of the other entry's 
NameServer: `openNameServerConfigDiff` passes the matched cluster's id together 
with `resolveOwningInstanceId(cluster)` (`:392-404`), which resolves the 
instance that owns the other address.
   
   ### Steps to Reproduce
   
   The regression test reproduces it without a live cluster (stubbed 
`listRegistryClusters` / `listNameserverRegistry` / `listInstances`): 
`web/src/pages/cluster/__tests__/ClusterPage.test.tsx`, "scopes a registry row 
to its own NameServer when another entry serves the same broker cluster name". 
It registers `k8s-edge` → `edge-ns:9876` and `DefaultCluster` → `prod-ns:9876`, 
returns the two probes the server would report (both with `nsClusterName: 
'DefaultCluster'`, in entry order) and clicks the diff action of the 
`prod-ns:9876` row:
   
   1. On `a92c2314`: `getNameServerConfigDiff` is called with 
`('DefaultCluster', 'instance-edge')` — the instance that owns `edge-ns:9876`.
   2. With the fix: `('DefaultCluster', 'instance-prod')`.
   
   On a real deployment the same steps are: register two NameServer registry 
entries whose NameServers each host a broker cluster named `DefaultCluster`, 
open Cluster → NameServer 管理, and use the diff action of the second entry's row.
   
   ### What Did You Expect to See?
   
   The diff dialog compares the NameServer address that the row shows. 
`NameServerConfigDiffService.compare(clusterId, instanceId)` should resolve the 
cluster through the entry's own address, so the report under the `prod-ns:9876` 
row lists `prod-ns:9876`.
   
   ### What Did You See Instead?
   
   The report is read from the other entry's NameServer. 
`getNameServerConfigDiff('DefaultCluster', 'instance-edge')` makes the service 
collect the NameServer addresses of the instance that owns `edge-ns:9876` 
(`NameServerConfigDiffService.compare:93-116` → `ClusterService.getCluster(id, 
instanceId)` → `RocketMQClusterProvider.refreshClusterDetail(clusterId, 
instanceId)` → `buildNameServerList(namesrvAddr)`), so the drift report 
displayed under the `prod-ns:9876` row belongs to `edge-ns:9876`.
   
   ### Additional Context
   
   A fix with a regression test follows in a pull request.
   
   ### Are You Willing to Submit a Pull Request?
   
   - [x] Yes, I am willing to submit a pull request.
   


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