iloveeyjafjalla opened a new pull request, #6863:
URL: https://github.com/apache/rocketmq-dashboard/pull/6863

   ## Which Issue(s) This PR Fixes
   
   Fixes #6862
   
   ## Problem / Evidence
   
   A plain create wrote the config built from the creation defaults, so a topic 
that already exists on the master was reset. Live on this stack:
   
   ```
   studio-e2e-check held 6/6 queues
     POST /api/topics/create 
{"name":"studio-e2e-check","type":"NORMAL","instanceId":"local-broker"}
     -> 200 success, broker topic now has 8 queues
   ro-probe-1 was created on the broker with -p 2 (write only)
     same create without a permission -> broker config shows "perm": 6
   ```
   
   `importing` is false for every REST and AI call, so `verifyTopicImport` 
never ran and `admin.createAndUpdateTopicConfig(addr, topicConfig)` always 
received the request defaults (queues 8 when omitted, `perm` RW when omitted). 
The group path carried the same shape - #5929 with #5930 open - where a 
re-create reset `retryQueueNums` and re-enabled consumption.
   
   ## Fix
   
   Mirror the group path from #5930: read the topic the master already holds, 
apply only the fields the request carries, and leave everything else as it is.
   
   ```java
   if (importing) {
       if (!verifyTopicImport(admin, brokerAddrs, topicConfig)) {
           for (String addr : brokerAddrs) { 
admin.createAndUpdateTopicConfig(addr, topicConfig); }
       }
   } else {
       for (String addr : brokerAddrs) {
           admin.createAndUpdateTopicConfig(addr, createConfigForMaster(admin, 
addr, topicConfig, topic));
       }
   }
   ```
   
   `createConfigForMaster` returns the request config when the master has no 
such topic, and otherwise keeps the existing queue counts, permission and 
message type unless the request carries them. Attributes are written in the 
protocol's add/alter form (`+message.type`): echoing the broker's read-form map 
back is rejected with `add/alter attribute format is wrong`, which the live run 
caught.
   
   The import path keeps its behaviour and its 409; only its comparison was 
extracted into `differsFromExistingTopic`/`examineTopicConfigIfPresent` so both 
paths share one definition.
   
   ## Tests
   
   `RocketMQAdminClientImplTest` gains two cases; with the old unconditional 
write both fail:
   
   ```
   createTopicKeepsTheExistingBrokerSettingsOfAnAlreadyPresentTopicTest -- 
expected: 6 but was: 8
   createTopicShouldNotResetAnExistingTopicWithoutCarriedFieldsTest -- 
expected: 6 but was: 8
   Tests run: 2, Failures: 2, Errors: 0, Skipped: 0
   ```
   
   After the change:
   
   ```
   Tests run: 175, Failures: 0, Errors: 0, Skipped: 0
     (RocketMQAdminClientImplTest 114, MetadataServiceTest 61)
   ```
   
   ## End-to-end verification
   
   Same stack, patched build beside the running one on port 8890:
   
   ```
   create without queue counts on the 6/6 topic   -> 200 and the broker keeps 6 
queues   (before: 8)
   create without perm on the write-only topic    -> 200 and the broker keeps 
"perm": 2  (before: 6)
   ```
   
   The probe topics were deleted afterwards. The change was prepared with AI 
assistance and reviewed, tested and verified by me.
   


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