Skip to content

Commit

Permalink
fix: return error when partition leader election failed for one of th…
Browse files Browse the repository at this point in the history
…e partitions
  • Loading branch information
achoimet committed Nov 21, 2024
1 parent 9887481 commit ea76846
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions extkafka/partition_attack_elect_new_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (f kafkaBrokerElectNewLeaderAttack) Start(ctx context.Context, state *Kafka

topicSet.Add(state.Topic, partitions...)

results, err := client.ElectLeaders(ctx, kadm.ElectPreferredReplica, topicSet)
results, err := client.ElectLeaders(ctx, kadm.ElectLiveReplica, topicSet)
if err != nil {
return nil, fmt.Errorf("failed to elect new leader for topic %s and partitions %s: %s", state.Topic, state.Partitions, err)
}
Expand All @@ -100,7 +100,7 @@ func (f kafkaBrokerElectNewLeaderAttack) Start(ctx context.Context, state *Kafka
for partition, result := range parts {
if result.Err != nil {
messages = append(messages, action_kit_api.Message{
Level: extutil.Ptr(action_kit_api.Warn),
Level: extutil.Ptr(action_kit_api.Error),
Message: fmt.Sprintf("Error while electing leader for topic '%s', partition %d, error is: %s", t, partition, result.Err.Error()),
})
} else {
Expand Down

0 comments on commit ea76846

Please sign in to comment.