Skip to content

Commit

Permalink
[kafka, kafka-manager]Fix for Debian 10 backports repo issue. (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-cs authored Apr 22, 2024
1 parent 553adf5 commit dc33dee
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions kafka/kafka-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,30 @@ function configure_and_start_cmak(){
./bin/cmak -Dconfig.file=conf/application.conf -Dhttp.port="${KAFKA_MANAGER_HTTP_PORT}" &
}

function remove_old_backports {
# This script uses 'apt-get update' and is therefore potentially dependent on
# backports repositories which have been archived. In order to mitigate this
# problem, we will remove any reference to backports repos older than oldstable

# https://github.com/GoogleCloudDataproc/initialization-actions/issues/1157
oldstable=$(curl -s https://deb.debian.org/debian/dists/oldstable/Release | awk '/^Codename/ {print $2}');
stable=$(curl -s https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename/ {print $2}');

matched_files="$(grep -rsil '\-backports' /etc/apt/sources.list*)"
if [[ -n "$matched_files" ]]; then
for filename in "$matched_files"; do
grep -e "$oldstable-backports" -e "$stable-backports" "$filename" || \
sed -i -e 's/^.*-backports.*$//' "$filename"
done
fi
}

function main(){
local java_major_version=$(java -version 2>&1 | grep -oP 'version "?(1\.)?\K\d+' || true)
OS=$(. /etc/os-release && echo "${ID}")
if [[ ${OS} == debian ]] && [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then
remove_old_backports
fi
if [[ ${java_major_version} -lt 11 ]]; then
echo "Error: Java 11 or higher is required for CMAK" >&2
echo "CMAK has not been installed" >&2
Expand Down
22 changes: 22 additions & 0 deletions kafka/kafka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,29 @@ function install_kafka_python_package() {
fi
}

function remove_old_backports {
# This script uses 'apt-get update' and is therefore potentially dependent on
# backports repositories which have been archived. In order to mitigate this
# problem, we will remove any reference to backports repos older than oldstable

# https://github.com/GoogleCloudDataproc/initialization-actions/issues/1157
oldstable=$(curl -s https://deb.debian.org/debian/dists/oldstable/Release | awk '/^Codename/ {print $2}');
stable=$(curl -s https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename/ {print $2}');

matched_files="$(grep -rsil '\-backports' /etc/apt/sources.list*)"
if [[ -n "$matched_files" ]]; then
for filename in "$matched_files"; do
grep -e "$oldstable-backports" -e "$stable-backports" "$filename" || \
sed -i -e 's/^.*-backports.*$//' "$filename"
done
fi
}

function main() {
OS=$(. /etc/os-release && echo "${ID}")
if [[ ${OS} == debian ]] && [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then
remove_old_backports
fi
recv_keys || err 'Unable to receive keys.'
update_apt_get || err 'Unable to update packages lists.'
install_kafka_python_package
Expand Down

0 comments on commit dc33dee

Please sign in to comment.