Description
The kafka-leader-election command does not set the process exit code to nonzero when an unexpected error occurs.
% bin/kafka-leader-election.sh --path-to-json-file /tmp/does-not-exist Missing required option(s): bootstrap-server, election-type org.apache.kafka.server.common.AdminCommandFailedException: Missing required option(s): bootstrap-server, election-type at org.apache.kafka.tools.LeaderElectionCommand$LeaderElectionCommandOptions.validate(LeaderElectionCommand.java:332) at org.apache.kafka.tools.LeaderElectionCommand.run(LeaderElectionCommand.java:78) at org.apache.kafka.tools.LeaderElectionCommand.main(LeaderElectionCommand.java:66) % echo "$?" 0
The exit code is sometimes set properly when other code paths cause the command to exit, or in versions < 3.7:
% bin/kafka-leader-election.sh This tool attempts to elect a new leader for a set of topic partitions. The type of elections supported are preferred replicas and unclean replicas. Option Description ------ ----------- ... % echo "$?" 1
This appears to be a regression in 3.7.0, and since a shell script may be relying on the return code from this command, this is something we should fix in the next release.
Attachments
Issue Links
- is caused by
-
KAFKA-14593 Move LeaderElectionCommand to tools
- Resolved
- links to