segmentio / topicctl

Tool for declarative management of Kafka topics
MIT License
580 stars 54 forks source link

[DP-1762] - topicctl get actions for under replicated and offline partitions #149

Closed ssingudasu closed 10 months ago

ssingudasu commented 10 months ago

Description

This PR is to add new actions for topicctl get

Expectations:

under replicated partitions

offline partitions

kafka-go metadata call for offline partitions gives the Leader partition information as below:

kafka "github.com/segmentio/kafka-go"

partition:

{
    Topic: topic_name
    ID: partition_id
    Leader: kafka.Broker (refer below)
    Replicas: [][Broker
    Isr:  [][Broker
    Error: kafka.Error
}

partition.Leader Broker response:

kafka.Broker{
        Host: ""
    Port: 0
    ID: 0
    Rack: ""
}

Unlike sarama which gives the offline leader broker id as -1, kafka-go gives the offline broker id as 0

Hence we will check the below error code: ListenerNotFound along with broker.Host as "" and broker.Port as 0 for partitions information in the metadata response

Expectation: if kafka.Error is ListenerNotFound and there is no broker or port found for leader partition, there by confirming that the partition is offline. We will display the ISR.ID and Repicas.ID with information from the kafka-go metadata call (i.e: each offline partition - Isr.ID and Replicas.ID as 0)

petedannemann commented 10 months ago

Could we document these new commands in the README with the other get commands?

ssingudasu commented 10 months ago

Closing this PR as we have decided to implement the same in

# topicctl get partitions