Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-16410

kafka-leader-election / LeaderElectionCommand doesn't set exit code on error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 3.7.0
    • 3.8.0, 3.7.1
    • tools

    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

          Activity

            People

              brandboat Kuan Po Tseng
              gharris1727 Greg Harris
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: