unbridled-41 opened a new pull request, #3151:
URL: https://github.com/apache/rocketmq-dashboard/pull/3151
## Problem / Evidence
Fixes #3103 (High/P1, filed by ai-yang, no existing PR claims it).
The Cluster page loads Broker rows from the global NameServer registry
through `listRegistryClusters()`, but Broker config preview/update and both
config-diff actions attached the instance selected by the page route
(`selectedInstanceIdRef.current`). After registry-based discovery (#2342), the
route instance and the source instance of a registry row are no longer
necessarily the same. With two instances reporting a shared cluster name such
as `DefaultCluster`, opening configuration for a row discovered from instance B
while the route points to instance A sent `{ id: "DefaultCluster", instanceId:
"instance-a" }` — a silent control-plane write to the wrong cluster.
## Root cause / Fix
- `web/src/pages/cluster/index.tsx` kept no instance identity on registry
rows; `buildConfigUpdateRequest`, `openBrokerConfigDiff`, and
`openNameServerConfigDiff` read the route instance.
- Each registry row is probed from one registered NameServer address, and
every Apache instance exposes its NameServer endpoint(s) via
`Instance.endpoint`. The page now resolves the row's owning instance by
tokenizing both endpoint sets (RocketMQ accepts comma/semicolon/space separated
address lists) and requiring a unique owner.
- Broker config preview/update, Broker config diff, and NameServer config
diff now target the resolved row instance. The config modal freezes its target
at open time, so a later route change cannot retarget the write.
- **Fail closed:** when zero or multiple instances own the endpoint, the
action is rejected with an explicit error message
(`cluster.registryTargetUnresolved`, zh/en) and no request is sent. I chose
click-time rejection with a clear message over disabling the buttons so
operators get actionable feedback; the safety property (no write/read against a
guessed instance) is identical.
Out of scope (kept for future work): discarding superseded broker-diff
responses within one modal generation, and per-row action disabling — neither
affects target correctness.
## Priority & scoring
- PRIORITY 83/100: impact 38/40 (silent wrong-instance production write:
flush mode, queue counts, permissions, retention), scope 15/20 (all registry
broker/ns config actions), reproducibility 16/20 (deterministic with two
instances sharing a cluster name), maintenance value 14/20 (localized fix,
clear contract).
- FIX_CONFIDENCE 82/100: endpoint→instance matching relies on instance
endpoints being NameServer addresses (verified:
`RuntimeAdminClientResolver.resolveEndpoint` feeds `Instance.endpoint` straight
into the admin client; `ClusterService.probeRegistryEntry` sets
`ClusterVO.endpoint` to the registry entry's address).
## Tests
- New regression tests in `ClusterPage.test.tsx` (all fail on the unfixed
source, verified by temporarily reverting `index.tsx`):
- cross-instance: route `/cluster?instanceId=instance-a`, row owned by
`ns-b:9876`/instance-b → preview and update requests carry `instanceId:
'instance-b'`;
- missing mapping: no instance owns the row endpoint → no
preview/update/diff request, error message shown, modal never opens;
- ambiguous mapping: two instances share the endpoint → action rejected,
no request.
- Existing NS-diff and broker-diff tests were kept green by aligning mock
fixtures so the mocked instance endpoint matches the mocked registry endpoint
(previously the fixtures were self-inconsistent in a way production cannot
produce).
- `npx vitest run src/pages/cluster src/i18n`: 7 files / 67 tests pass.
- `npx tsc -p tsconfig.app.json --noEmit` and `eslint` on changed files:
clean.
## Risk
Medium-low: config actions now fail closed for registry rows whose endpoint
cannot be uniquely mapped to a configured Apache instance (previously they
executed against the route instance). Operators who relied on that accidental
fallback must register the row's NameServer on the owning instance. Read-only
discovery, metrics, and the route-scoped instance summary are unchanged.
--
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]