You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jesse Gorzinski (Jira)" <ji...@apache.org> on 2020/07/14 20:49:00 UTC

[jira] [Created] (KAFKA-10272) kafka-server-stop.sh fails on IBM i

Jesse Gorzinski created KAFKA-10272:
---------------------------------------

             Summary: kafka-server-stop.sh fails on IBM i
                 Key: KAFKA-10272
                 URL: https://issues.apache.org/jira/browse/KAFKA-10272
             Project: Kafka
          Issue Type: Bug
          Components: core
    Affects Versions: 2.5.0
         Environment: IBM i 7.2
            Reporter: Jesse Gorzinski


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:
{code:java}
PIDS=$(ps ax | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $1}')
{code}
On IBM i, the ps utility is unconventional and truncates the output with these arguments. For instance, here is part of the ps output
{code:java}
 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
{code}
 

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 
{code:java}
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

{code}
So.... the following PID check works for IBM i:

 
{code:java}
PIDS=$(ps -af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
{code}
so, a fix would be (I have verified this):
{code:java}
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
{code}
This all also applies to `zookeeper-server-stop.sh`



--
This message was sent by Atlassian Jira
(v8.3.4#803005)