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
- links to