This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new b2945a800 fix(cluster): resolve a registry row to its own NameServer
cluster (#6816)
b2945a800 is described below
commit b2945a800ae1cd9814f0b958933d7791512a4c05
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:44:41 2026 +0800
fix(cluster): resolve a registry row to its own NameServer cluster (#6816)
---
.../pages/cluster/__tests__/ClusterPage.test.tsx | 112 +++++++++++++++++++++
web/src/pages/cluster/index.tsx | 8 +-
2 files changed, 118 insertions(+), 2 deletions(-)
diff --git a/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
b/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
index d4d2f20f4..b19dd4f15 100644
--- a/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
+++ b/web/src/pages/cluster/__tests__/ClusterPage.test.tsx
@@ -994,6 +994,118 @@ describe('Cluster page', () => {
).toBeInTheDocument();
});
+ it('scopes a registry row to its own NameServer when another entry serves
the same broker cluster name', async () => {
+ const user = userEvent.setup({ pointerEventsCheck: 0 });
+ instanceServiceMocks.listInstances.mockResolvedValue([
+ {
+ id: 10,
+ name: 'instance-edge',
+ endpoint: 'edge-ns:9876',
+ type: 'DIRECT',
+ vendor: 'APACHE',
+ remark: '',
+ topicCount: 0,
+ consumerGroupCount: 0,
+ gmtCreate: '',
+ gmtModified: '',
+ },
+ {
+ id: 11,
+ name: 'instance-prod',
+ endpoint: 'prod-ns:9876',
+ type: 'DIRECT',
+ vendor: 'APACHE',
+ remark: '',
+ topicCount: 0,
+ consumerGroupCount: 0,
+ gmtCreate: '',
+ gmtModified: '',
+ },
+ ]);
+ // Both entries are backed by a broker cluster named `DefaultCluster` (the
RocketMQ default)
+ // and the older entry comes first, which mirrors the server:
ClusterService probes the
+ // registry in id order and overwrites each probe with name = entry name
and
+ // nsClusterName = the broker cluster name discovered behind that entry's
NameServer.
+ clusterServiceMocks.listRegistryClusters.mockResolvedValue([
+ {
+ ...buildCluster(),
+ id: 'DefaultCluster',
+ name: 'k8s-edge',
+ nsClusterName: 'DefaultCluster',
+ endpoint: 'edge-ns:9876',
+ nameServers: [{ addr: 'edge-ns:9876', status: 'healthy' }],
+ },
+ {
+ ...buildCluster(),
+ id: 'DefaultCluster',
+ name: 'DefaultCluster',
+ nsClusterName: 'DefaultCluster',
+ endpoint: 'prod-ns:9876',
+ nameServers: [{ addr: 'prod-ns:9876', status: 'healthy' }],
+ },
+ ]);
+ clusterServiceMocks.listNameserverRegistry.mockResolvedValue([
+ {
+ id: 1,
+ name: 'k8s-edge',
+ namesrvAddr: 'edge-ns:9876',
+ k8sNamespace: 'edge',
+ k8sId: 'ack-edge',
+ status: 'healthy',
+ description: null,
+ gmtCreate: '2026-08-17 19:15:37',
+ gmtModified: '2026-08-17 19:15:37',
+ },
+ {
+ id: 2,
+ name: 'DefaultCluster',
+ namesrvAddr: 'prod-ns:9876',
+ k8sNamespace: 'prod',
+ k8sId: 'ack-prod',
+ status: 'healthy',
+ description: null,
+ gmtCreate: '2026-08-17 19:15:37',
+ gmtModified: '2026-08-17 19:15:37',
+ },
+ ]);
+ clusterServiceMocks.getNameServerConfigDiff.mockImplementation(
+ async (_clusterId: string, instanceId?: string) => ({
+ cluster: 'DefaultCluster',
+ complete: true,
+ driftDetected: false,
+ nodeCount: 1,
+ reachableNodeCount: 1,
+ comparedKeys: ['serverWorkerThreads'],
+ nodes: [
+ {
+ address: instanceId === 'instance-prod' ? 'prod-ns:9876' :
'edge-ns:9876',
+ reachable: true,
+ },
+ ],
+ differences: [],
+ }),
+ );
+ renderWithProviders(<ClusterPage />);
+
+ await user.click(screen.getByRole('tab', { name: /NameServer 管理/ }));
+ const row = await screen.findByRole('row', { name: /prod-ns:9876/ });
+ await user.click(within(row).getByRole('button', { name: /配置差异/ }));
+
+ // The row must ask for the NameServer it names, not for the older entry
whose NameServer
+ // happens to serve a broker cluster with the same name.
+ await waitFor(() =>
+ expect(clusterServiceMocks.getNameServerConfigDiff).toHaveBeenCalledWith(
+ 'DefaultCluster',
+ 'instance-prod',
+ ),
+ );
+ const dialog = await screen.findByRole('dialog', {
+ name: /NameServer 配置差异 - DefaultCluster/,
+ });
+ expect(within(dialog).getByText('prod-ns:9876')).toBeInTheDocument();
+ expect(within(dialog).queryByText('edge-ns:9876')).not.toBeInTheDocument();
+ });
+
it('omits instanceId for NameServer config drift when no instance owns the
registry cluster', async () => {
const user = userEvent.setup({ pointerEventsCheck: 0 });
clusterServiceMocks.listRegistryClusters.mockResolvedValue([
diff --git a/web/src/pages/cluster/index.tsx b/web/src/pages/cluster/index.tsx
index e2514f82e..dc114b1b4 100644
--- a/web/src/pages/cluster/index.tsx
+++ b/web/src/pages/cluster/index.tsx
@@ -385,6 +385,11 @@ const ClusterPage = () => {
[loadNsRegistry, t],
);
+ // A registry entry owns the probes whose endpoint or address is its own
namesrvAddr (the
+ // probe overwrites endpoint with that address and name with the entry
name). nsClusterName
+ // is the broker cluster name discovered behind the probed NameServer, so
two entries can
+ // report the same one — matching it pairs the row with whichever of them
was registered
+ // first and reads the config of the wrong NameServer.
const resolveNameserverRegistryCluster = useCallback(
(entry: NameserverRegistryEntry) => {
const namesrvAddr = safeText(entry.namesrvAddr);
@@ -393,8 +398,7 @@ const ClusterPage = () => {
(cluster) =>
cluster.endpoint === namesrvAddr ||
cluster.nameServers.some((nameServer) => nameServer.addr ===
namesrvAddr) ||
- cluster.name === name ||
- cluster.nsClusterName === name,
+ cluster.name === name,
);
},
[registryClusters],