Greg Harris created KAFKA-16410:
-----------------------------------

             Summary: kafka-leader-election / LeaderElectionCommand doesn't set 
exit code on error
                 Key: KAFKA-16410
                 URL: https://issues.apache.org/jira/browse/KAFKA-16410
             Project: Kafka
          Issue Type: Bug
          Components: tools
    Affects Versions: 3.7.0
            Reporter: Greg Harris
             Fix For: 3.7.1


The kafka-leader-election command does not set the process exit code to nonzero 
when an unexpected error occurs.
{noformat}
% 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
{noformat}
The exit code is sometimes set properly when other code paths cause the command 
to exit, or in versions < 3.7:
{noformat}
% 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
{noformat}
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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to