dajac opened a new pull request #10141:
URL: https://github.com/apache/kafka/pull/10141


   `kafka-reassign-partitions` command gives a generic error message when one 
tries to reassign a topic which does not exist:
   
   ```
   $ ./bin/kafka-reassign-partitions.sh --bootstrap-server localhost:9092 
--execute --reassignment-json-file reassignment.json
   Error: org.apache.kafka.common.errors.UnknownTopicOrPartitionException: This 
server does not host this topic-partition.
   ```
   
   When the reassignment contains multiple topics, it is hard to find out the 
correct one. This PR improves this to give the name of the topic in the error:
   
   ```
   $ ./bin/kafka-reassign-partitions.sh --bootstrap-server localhost:9092 
--execute --reassignment-json-file reassignment.json
   Error: org.apache.kafka.common.errors.UnknownTopicOrPartitionException: 
Topic test-test not found.
   ```
   
   I propose to update the `KafkaAdminClient#describeTopics` method to handle 
this case directly. I noted that the unit tests of the 
`ReassignPartitionsCommand` already expects to find the topic name in the 
error. This works in unit test because the `MockAdminClient` does that. When 
the regular admin client is used however, the generic message is used except 
when the topic is not in the response received from the broker at all. This PR 
makes the handling and the error consistent in all cases in the 
`KafkaAdminClient#describeTopics`.
   
   Alternatively, we could handle this entirely in the 
`ReassignPartitionsCommand`. We could catch the exception and raise a new one 
with the message that we want. I don't feel strong for either ways so I went 
with doing it in the admin client.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to