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

kafka-server-stop.sh fails on IBM i

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.0
    • Fix Version/s: 2.7.0
    • Component/s: core
    • Labels:
    • Environment:
      IBM i 7.2

      Description

      On the IBM i platform, the `kafka-server-stop.sh` script always fails with an error message "No kafka server to stop"

       

      The underlying cause is because the script relies on the output of `ps ax` to determine the pid. More specifically:

      PIDS=$(ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}')
      

      On IBM i, the ps utility is unconventional and truncates the output with these arguments. For instance, here is part of the ps output

       584329      - A     0:00 /QOpenSys/QIBM/ProdData/SC1/OpenSSH/sbin/sshd -R
       584331      - A     0:00 /QOpenSys/QIBM/ProdData/SC1/OpenSSH/libexec/sftp-serv
       584332      - A     0:00 /QOpenSys/QIBM/ProdData/SC1/OpenSSH/sbin/sshd -R
       584334  pts/5 A     0:00 -bash
       584365  pts/7 A     0:08 java -Xmx512M -Xms512M -server -XX:+UseG1GC -XX:MaxGC
       585353  pts/8 A     0:12 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPaus
       585690  pts/9 A     0:00 ps ax
      

       

      Therefore, the resultant grep always comes up empty. When invoked with `ps -af`, it gives the whole command (when piped) but sticks in the UID by default 

      ps -af
           UID    PID   PPID   C    STIME    TTY  TIME CMD
      jgorzins 585353 583321   0 12:41:07  pts/8  0:41 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurr
      jgorzins 585817 585794   0 14:44:25  pts/4  0:00 ps -af
      
      

      So.... the following PID check works for IBM i:

       

      PIDS=$(ps -af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
      

      so, a fix would be (I have verified this):

      if [[ "OS400" == $(uname -s) ]]; then
        PIDS=$(ps -af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
      else
        PIDS=$(ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}')
      fi
      

      This all also applies to `zookeeper-server-stop.sh`

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ThePrez Jesse Gorzinski
                Reporter:
                ThePrez Jesse Gorzinski
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified