On Thu, Apr 25, 2019 at 11:47 AM Jason Gustafson <ja...@confluent.io> wrote:
>
> Hi Jose,
>
> This looks useful. One comment I had is whether we can improve the leader
> election tool. Needing to provide a json file is a bit annoying. Could we
> have a way to specify partitions directly through the command line? Often
> when we need to enable unclean leader election, it is just one or a small
> set of partitions.  I'd hope to be able to do something like this.
>
> bin/kafka-elect-leaders.sh --allow-unclean --topic foo --partition 1
> --bootstrap-server localhost:9092

Thanks for the feedback Jason. How about the following help output for
those flags:

--election-type <String: election>
Type of election to attempt. Possible values are 0 (or "preferred") for
preferred election or 1 (or "uncleaned") for uncleaned election. The
default value is 0 (or "preferred"), if --topic and --partition is
specified . Not allowed if --path-to-json-file is specified.

--topic <String: topic>
Name of topic for which to perform an election. REQUIRED if --partition is
specified. Not allowed if --path-to-json-file is specified.

--partition <Integer: partition id>
Partition id for which to perform an election. REQUIRED if --topic is
specified. Not allowed if --path-to-json-file is specified.

--path-to-json-file <String: file path>
...
Defaults to preferred election to all existing partitions if --topic and
--partition flags are not specified.

>
> Also there's a comment if the json file is not provided, the help document
> says "Defaults to all existing partitions." I assume we would not keep
this
> behavior?

Unfortunately, this behaviour is at the protocol level. If the Kafka
controller receives a request with a null for "TopicPartitions" then it
assumes that the user is attempting to perform a preferred leader election
on all of the partitions. I am not sure if we can remove this functionality
at this point. We could remove this feature from the CLI/command while
keeping it at the protocol level. What do we think?

This is the code that handles this:
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/server/KafkaApis.scala#L2365-L2366

>
> The only other question I had is whether we ought to deprecate
> `AdminClient.electPreferredLeaders`?

Yes. We should deprecate this method. I'll update the KIP.

Thanks!

Reply via email to