X-LightYear opened a new issue, #4897:
URL: https://github.com/apache/rocketmq-dashboard/issues/4897
## Before Creating the Bug Report
- [x] I have searched the existing Issues and PRs and found no matching
report.
- [x] This defect belongs to RocketMQ Studio.
- [x] I reproduced the behavior on the current development trunk.
## Studio Version
- Branch: `master`
- Commit: `d50ffecc9d7e8f8f46da64198831bd7952e6974e`
- Deployment: built from source
## Runtime Environment
- OS: Windows 11
- JDK: OpenJDK 21.0.7 (IntelliJ JBR)
- Maven: 3.9.10
## Connected RocketMQ Cluster
- RocketMQ version: 5.5.0
- Access mode: Direct to NameServer/Broker
## Describe the Bug
When an instance-scoped cluster lookup cannot return a live cluster, cluster
configuration preview resolves the cluster from the global repository by
`clusterId`. The repository entry is not bound to an instance, so a cluster
from a different instance can be used for the requested instance.
## Steps to Reproduce
1. Start from `master` at commit `d50ffecc9d7e8f8f46da64198831bd7952e6974e`.
2. Make an instance-scoped lookup for `cluster-1` under `instance-a` return
no live cluster.
3. Leave a global repository entry for `cluster-1`.
4. Call `previewClusterConfig` with `{id: cluster-1, instanceId: instance-a,
flushDiskType: SYNC_FLUSH}`.
5. Observe that a preview for the global cluster is returned instead of
reporting the target cluster as unavailable.
A deterministic regression test is:
`ClusterServiceTest.previewClusterConfigShouldNotUseGlobalClusterWhenInstanceScopedLookupFails`
## What Did You Expect to See?
An instance-scoped miss should remain unavailable and return a 503 response;
no global cluster should be substituted.
## What Did You See Instead?
The current code falls back to `clusterRepository.findById(clusterId)` and
returns the global cluster preview.
## Root Cause
`ClusterService.resolveCluster(clusterId, instanceId)` preserves a legacy
global fallback even when `instanceId` is nonblank. Unlike `getCluster(id,
instanceId)`, it does not keep the lookup scoped to the selected instance.
Since persisted `ClusterVO` entries have no instance binding, the fallback
cannot establish ownership.
## Regression Evidence
Focused Maven test on current `master` with JDK 21.0.7:
```text
mvn
-Dtest=ClusterServiceTest#previewClusterConfigShouldNotUseGlobalClusterWhenInstanceScopedLookupFails
test
```
Result: 1 test run, 1 failure: `Expecting code to raise a throwable.`
## Scope
Keep instance-scoped configuration preview/update resolution within the
selected instance and report the cluster as unavailable when the provider
cannot resolve it. Preserve the existing fallback for legacy clusterId-only
lookups.
--
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]