-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DP-1774] - topicctl get partitions to display under replicated and offline #155
Conversation
pkg/admin/brokerclient.go
Outdated
|
||
client := c.GetConnector().KafkaClient | ||
req := kafka.MetadataRequest{ | ||
Topics: allTopics, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just pass through nil here instead of fetching all the topics to get metadata for the all topics. Also, we already have a getMetadata
method in this file. Should we use that instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func getMetadata is in brokerclient and not in zkclient.
For consistency in code, I made following modification - 9a9b80f
This has been tested in local as well
If this looks good, Can you please resolve this conversation.
All comments have been resolved. Merging the PR |
Description:
topicctl get partitions
currently displays the partitions status information as below:Out-of-sync: This mean either under-replicated or offline partition
Wrong Leader: This means partition does not have preferred leader replica
Ok: This means partition is in a good state (inSync)
We need to know whether a partition is ok (inSync), under-replicated, offline and also check if the partition has a preferred replica leader.
Current topicctl get partitions problems/gaps:
topicctl get partitions
Expectations:This PR will add following features to topicctl
topicctl get partitions
-> gets all topics partitions informationtopicctl get partitions --status <ok|offline|under-replicated>
-> gets all topics partitions information for specified statustopicctl get partitions --summary
-> Get the summary of all topics partitions statustopicctl get partitions
should take 0 or any number of topic arguments. (Before, get partitions was taking only 1 topic argument)repl> get partitions <topic> [--summary]
(refer below for repl expectations)topicctl:repl> get partitions
Expectations:From terminal, topicctl get partitions can take more than one argument.
From repl, filtering multiple topics can get tricky. Current repl implementation takes only fixed number of words (command.args).
Hence in repl, we will make get partitions work with only one argument (topic) and PartitionStatus as "" implying all status
Partition Status:
Preferred Leader:
Considerations:
Local Set UP Details:
Build
topicctl get partitions --broker-addr localhost:19092
GOOS=linux GOARCH=amd64 go build -o ./build/topicctl-linux-amd64 -a ./cmd/topicctl
docker cp ./build/topicctl-linux-amd64 zookeeper:/tmp
docker exec -u root -it zookeeper /tmp/topicctl-linux-amd64 get partitions --zk-addr localhost:2181
topicctl get partitions --help
# ./build/topicctl get partitions --help
Partitions Information
Created a topic threepartition
topic: threepartition
Get all partitions status
# ./build/topicctl get partitions --broker-addr localhost:19092
# docker exec -u root -it zookeeper /tmp/topicctl-linux-amd64 get partitions --zk-addr localhost:2181
Get all partitions status summary
# ./build/topicctl get partitions --broker-addr localhost:19092 --summary
# docker exec -u root -it zookeeper /tmp/topicctl-linux-amd64 get partitions --zk-addr localhost:2181 --summary
Kill Broker IDs 1, 2
# docker stop kafka-2; docker stop kafka-3
Getting current all partition status
# ./build/topicctl get partitions --broker-addr localhost:19092
# docker exec -u root -it zookeeper /tmp/topicctl-linux-amd64 get partitions --zk-addr localhost:2181
Get current all partitions status --summary
# ./build/topicctl get partitions --broker-addr localhost:19092 --summary
# docker exec -u root -it zookeeper /tmp/topicctl-linux-amd64 get partitions --zk-addr localhost:2181 --summary
start broker ID 1
docker start kafka-2
Getting current all partition status
# ./build/topicctl get partitions --broker-addr localhost:19092
repl and get partitions info for
topic: __consumer_offsets
# ./build/topicctl repl --broker-addr localhost:19092
# get partitions __consumer_offsets
# get partitions __consumer_offsets --summary
NOTE: repl can take only one topic argument and optional flag --summary
start broker ID 2
# docker start kafka-3
Getting current all partition status and filter for test-1, threepartition
# ./build/topicctl get partitions --broker-addr localhost:29092
# ./build/topicctl get partitions test-1 threepartition --broker-addr localhost:29092 --summary
# ./build/topicctl get partitions test-1 threepartition --broker-addr localhost:29092 --summary --status under-replicated
Getting stable all partition status
# ./build/topicctl get partitions --broker-addr localhost:29092
running preferred leader for topic: partitionthree fixes the wrong leader
Before preferred leader:
# ./build/topicctl get partitions threepartition --broker-addr localhost:29092
After preferred leader:
# ./build/topicctl get partitions threepartiton --broker-addr localhost:29092
threepartition summary:
# ./build/topicctl get partitions threepartition --broker-addr localhost:29092 --summary
threepartition topic summary filter for status ok:
# ./build/topicctl get partitions threepartition --broker-addr localhost:29092 --summary --status ok
fetching partition information for topic that does not displays error message
# ./build/topicctl get partitions topicdoesnotexist --broker-addr localhost:29092