Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(risedev): always download latest Kafka #15514

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion ci/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ function filter_stack_trace() {
| sed -E '/ at ...cargo/d' > tmp
cp tmp "$1"
rm tmp
}
}

get_latest_kafka_version() {
local versions=$(curl -s https://downloads.apache.org/kafka/ | grep -Eo 'href="[0-9]+\.[0-9]+\.[0-9]+/"' | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
# Sort the version numbers and get the latest one
local latest_version=$(echo "$versions" | sort -V | tail -n1)
echo $latest_version
}

get_latest_kafka_download_url() {
local latest_version=$(get_latest_kafka_version)
local download_url="https://downloads.apache.org/kafka/${latest_version}/kafka_2.13-${latest_version}.tgz"
echo $download_url
}
4 changes: 2 additions & 2 deletions ci/scripts/gen-flamegraph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ install_all() {
promql --version

echo ">>> Installing Kafka"
wget https://archive.apache.org/dist/kafka/3.4.1/kafka_2.13-3.4.1.tgz
tar -zxvf kafka_2.13-3.4.1.tgz
wget $(get_latest_kafka_download_url) -O kafka_latest.tgz
tar -zxvf kafka_latest.tgz

echo ">>> Installing nexmark bench"
buildkite-agent artifact download nexmark-server /usr/local/bin
Expand Down
22 changes: 15 additions & 7 deletions src/risedevtool/kafka.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ extend = "common.toml"

[env]
KAFKA_DOWNLOAD_PATH = "${PREFIX_TMP}/kafka.tgz"
KAFKA_VERSION = "3.4.1"
KAFKA_SCALA_VERSION = "2.13"
KAFKA_RELEASE = "kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}"
KAFKA_DOWNLOAD_RECENT_TGZ = "https://dlcdn.apache.org/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz"
KAFKA_DOWNLOAD_ARCHIVE_TGZ = "https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz"

[tasks.download-kafka]
private = true
Expand All @@ -20,9 +15,22 @@ set -e
if [ -d "${PREFIX_BIN}/kafka" ]; then
exit 0
fi

get_latest_kafka_version() {
local versions=$(curl -s https://downloads.apache.org/kafka/ | grep -Eo 'href="[0-9]+\.[0-9]+\.[0-9]+/"' | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
# Sort the version numbers and get the latest one
local latest_version=$(echo "$versions" | sort -V | tail -n1)
echo $latest_version
}

get_latest_kafka_download_url() {
local latest_version=$(get_latest_kafka_version)
local download_url="https://downloads.apache.org/kafka/${latest_version}/kafka_2.13-${latest_version}.tgz"
echo $download_url
}

echo "Kafka not found, download ${KAFKA_RELEASE}"
curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "${KAFKA_DOWNLOAD_RECENT_TGZ}" \
|| curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "${KAFKA_DOWNLOAD_ARCHIVE_TGZ}"
curl -fL -o "${KAFKA_DOWNLOAD_PATH}" "$(get_latest_kafka_download_url)"
tar -xf "${KAFKA_DOWNLOAD_PATH}" -C "${PREFIX_TMP}"
mv "${PREFIX_TMP}/${KAFKA_RELEASE}" "${PREFIX_BIN}/kafka"
rm ${KAFKA_DOWNLOAD_PATH}
Expand Down
Loading