yangjj-iso opened a new pull request, #7661:
URL: https://github.com/apache/shenyu/pull/7661

   Fixes #6461.
   
   In cluster mode, `masterCheck()` closes a connection to a non-master Admin 
but never uses the `masterUrl` returned in its RUNNING_MODE reply. Retrying 
only the configured load-balanced URL can repeatedly select the same non-master 
pod. The check also closes an open connection whose running-mode reply has not 
arrived yet.
   
   Follow a valid advertised ws/wss master address after an explicit 
CLUSTER/non-master reply. Deduplicate targets and reuse an existing master 
connection. Keep the configured seed URLs for later recovery, and construct 
redirected clients through the existing factory so token, Origin, namespace, 
gateway port, subscribers, and initial-readiness settings are retained. Invalid 
addresses fall back to the existing seed retry flow.
   
   Keep open connections while the mode reply is pending. Reset the previous 
role/address when a socket opens again, make the cross-thread fields visible, 
and publish the running mode after the reply's address/role have been recorded.
   
   Add 12 regression/guard cases, including real local WebSocket servers that 
simulate one or two non-master seeds advertising the same master. Verify 
configuration reaches the subscriber through the master, only one master 
connection is opened, headers/namespace survive redirection, and seed URLs 
remain unchanged. Also cover delayed replies, invalid addresses, an 
already-connected master, seed fallback after a closed redirected connection, 
and clearing stale role state on reopen. Timers are mocked and checks are 
invoked directly; no 60-second sleeps are needed.
   
   Validation:
   - On the original implementation, 4 of the 12 new cases fail: both real 
master-redirect scenarios, the delayed-reply case, and the stale-role case.
   - After the fix, all 139 selected tests pass (132 in the WebSocket sync 
module and 7 base handler tests), with zero failures/errors/skips.
   - Checkstyle and Apache RAT pass across the affected reactor; `git diff 
--check` passes.
   - Full-repository install and a deployed Kubernetes/Admin cluster were not 
run locally.
   
   ```sh
   ./mvnw -B -ntp -pl shenyu-sync-data-center/shenyu-sync-data-websocket -am 
test \
     
'-Dtest=WebsocketMasterRedirectTest,WebsocketSyncDataServiceTest,ShenyuWebsocketClientTest,InitialSyncStateTest,InitialSyncConnectionTest,WebsocketConfigTest,*DataHandlerTest'
 \
     -Dsurefire.failIfNoSpecifiedTests=false -DskipRemoteResources=true \
     -Djacoco.skip=true -Dmaven.javadoc.skip=true
   ./mvnw -B -ntp -pl shenyu-sync-data-center/shenyu-sync-data-websocket -am 
apache-rat:check -DskipRemoteResources=true
   ```
   
   - [x] Read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide/).
   - [x] Submit regression tests.
   - [ ] Full local `./mvnw clean install -Dmaven.javadoc.skip=true` 
(affected-reactor validation above).
   


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