mirror of https://github.com/apache/kafka.git
KAFKA-15471 [MINOR]: Fix backward-compatibility bug (#14996)
Fixes a backwards-compatibility issue in the KIP-979 change to the kafka-server-stop.sh script where it would not stop processes if run from a directory that differed from the directory where the processes were started form and the config file specified at start time was a relative path. Reviewers: Ron Dagostino <rdagostino@confluent.io>
This commit is contained in:
parent
4ce3bcd767
commit
9d1cbf54f8
|
@ -31,17 +31,6 @@ elif [[ "$OSNAME" == "OS400" ]]; then
|
||||||
PIDS=$(ps -Af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
|
PIDS=$(ps -Af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}')
|
||||||
else
|
else
|
||||||
PIDS=$(ps ax | grep ' kafka\.Kafka ' | grep java | grep -v grep | awk '{print $1}'| xargs)
|
PIDS=$(ps ax | grep ' kafka\.Kafka ' | grep java | grep -v grep | awk '{print $1}'| xargs)
|
||||||
RelativePathToConfig=$(ps ax | grep ' kafka\.Kafka ' | grep java | grep -v grep | sed 's/--override property=[^ ]*//g' | awk 'NF>1{print $NF}' | xargs)
|
|
||||||
IFS=' ' read -ra RelativePathArray <<< "$RelativePathToConfig"
|
|
||||||
declare -a AbsolutePathToConfigArray
|
|
||||||
for ((i = 0; i < ${#RelativePathArray[@]}; i++)); do
|
|
||||||
AbsolutePathToConfig=$(readlink -f "${RelativePathArray[i]}")
|
|
||||||
if [ -z "$AbsolutePathToConfig" ]; then
|
|
||||||
echo "Can not find the configuration file in the current directory. Please make sure the kafka stop process and the start process are called in the same directory."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
AbsolutePathToConfigArray+=("$AbsolutePathToConfig")
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$PIDS" ]; then
|
if [ -z "$PIDS" ]; then
|
||||||
|
@ -51,14 +40,21 @@ else
|
||||||
if [ -z "$INPUT_PROCESS_ROLE" ] && [ -z "$INPUT_NID" ]; then
|
if [ -z "$INPUT_PROCESS_ROLE" ] && [ -z "$INPUT_NID" ]; then
|
||||||
kill -s $SIGNAL $PIDS
|
kill -s $SIGNAL $PIDS
|
||||||
else
|
else
|
||||||
|
RelativePathToConfig=$(ps ax | grep ' kafka\.Kafka ' | grep java | grep -v grep | sed 's/--override property=[^ ]*//g' | awk 'NF>1{print $NF}' | xargs)
|
||||||
IFS=' ' read -ra PIDSArray <<< "$PIDS"
|
IFS=' ' read -ra PIDSArray <<< "$PIDS"
|
||||||
for ((i = 0; i < ${#AbsolutePathToConfigArray[@]}; i++)); do
|
IFS=' ' read -ra RelativePathArray <<< "$RelativePathToConfig"
|
||||||
|
for ((i = 0; i < ${#RelativePathArray[@]}; i++)); do
|
||||||
|
AbsolutePathToConfig=$(readlink -f "${RelativePathArray[i]}")
|
||||||
|
if [ -z "$AbsolutePathToConfig" ] ; then
|
||||||
|
echo "Can not find the configuration file in the current directory. Please make sure the kafka stop process and the start process are called in the same directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if [ -n "$INPUT_NID" ] ; then
|
if [ -n "$INPUT_NID" ] ; then
|
||||||
keyword="node.id="
|
keyword="node.id="
|
||||||
NID=$(sed -n "/$keyword/ { s/$keyword//p; q; }" "${AbsolutePathToConfigArray[i]}")
|
NID=$(sed -n "/$keyword/ { s/$keyword//p; q; }" "$AbsolutePathToConfig")
|
||||||
elif [ -n "$INPUT_PROCESS_ROLE" ] && [ -z "$INPUT_NID" ]; then
|
elif [ -n "$INPUT_PROCESS_ROLE" ] && [ -z "$INPUT_NID" ]; then
|
||||||
keyword="process.roles="
|
keyword="process.roles="
|
||||||
PROCESS_ROLE=$(sed -n "/$keyword/ { s/$keyword//p; q; }" "${AbsolutePathToConfigArray[i]}")
|
PROCESS_ROLE=$(sed -n "/$keyword/ { s/$keyword//p; q; }" "$AbsolutePathToConfig")
|
||||||
fi
|
fi
|
||||||
if [ -n "$INPUT_PROCESS_ROLE" ] && [ "$PROCESS_ROLE" == "$INPUT_PROCESS_ROLE" ] || [ -n "$INPUT_NID" ] && [ "$NID" == "$INPUT_NID" ]; then
|
if [ -n "$INPUT_PROCESS_ROLE" ] && [ "$PROCESS_ROLE" == "$INPUT_PROCESS_ROLE" ] || [ -n "$INPUT_NID" ] && [ "$NID" == "$INPUT_NID" ]; then
|
||||||
kill -s $SIGNAL ${PIDSArray[i]}
|
kill -s $SIGNAL ${PIDSArray[i]}
|
||||||
|
|
Loading…
Reference in New Issue