This is an automated email from the ASF dual-hosted git repository. rndgstn pushed a commit to branch 3.7 in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/3.7 by this push: new 9d1cbf54f83 KAFKA-15471 [MINOR]: Fix backward-compatibility bug (#14996) 9d1cbf54f83 is described below commit 9d1cbf54f837b82cc66a4cfbbc75784ac715559f Author: Hailey Ni <136509748+hni61...@users.noreply.github.com> AuthorDate: Thu Dec 14 07:32:16 2023 -0800 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 <rdagost...@confluent.io> --- bin/kafka-server-stop.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/kafka-server-stop.sh b/bin/kafka-server-stop.sh index e02a69c47ed..2f1bf86a411 100755 --- a/bin/kafka-server-stop.sh +++ b/bin/kafka-server-stop.sh @@ -31,17 +31,6 @@ elif [[ "$OSNAME" == "OS400" ]]; then PIDS=$(ps -Af | grep -i 'kafka\.Kafka' | grep java | grep -v grep | awk '{print $2}') else 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 if [ -z "$PIDS" ]; then @@ -51,14 +40,21 @@ else if [ -z "$INPUT_PROCESS_ROLE" ] && [ -z "$INPUT_NID" ]; then kill -s $SIGNAL $PIDS 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" - 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 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 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 if [ -n "$INPUT_PROCESS_ROLE" ] && [ "$PROCESS_ROLE" == "$INPUT_PROCESS_ROLE" ] || [ -n "$INPUT_NID" ] && [ "$NID" == "$INPUT_NID" ]; then kill -s $SIGNAL ${PIDSArray[i]}