Skip to content

Commit 5d646d0

Browse files
nickgoodingweeco
authored andcommitted
fix: ensure each broker is preferred leader for a partition
The end-to-end monitoring service already includes a process to validate that each broker is the preferred leader for at least one partition, but this validation was not run for brokers that were not the preferred leader for any partitions. For example, this would mean an additional partition would never be created after the initial creation of the management topic in the case of another broker being added to the cluster. This fix could be a breaking change for users without the required permissions to create partitions or alter partition assignments if they have inadvertently relied on this feature not working as documented.
1 parent 7bed85e commit 5d646d0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

e2e/topic.go

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (s *Service) calculatePartitionReassignments(meta *kmsg.MetadataResponse) (
169169
// We want to ensure that each brokerID leads at least one partition permanently. Hence let's iterate over brokers.
170170
preferredLeaderPartitionsBrokerID := make(map[int32][]kmsg.MetadataResponseTopicPartition)
171171
for _, broker := range brokerByID {
172+
preferredLeaderPartitionsBrokerID[broker.NodeID] = make([]kmsg.MetadataResponseTopicPartition, 0)
172173
for _, partition := range topicMeta.Partitions {
173174
// PreferredLeader = BrokerID of the brokerID that is the desired leader. Regardless who the current leader is
174175
preferredLeader := partition.Replicas[0]

0 commit comments

Comments
 (0)