From 5e4fbd015380b01b5980a0d3d1bed15bae27b20e Mon Sep 17 00:00:00 2001 From: "C.J. Collier" Date: Fri, 19 Apr 2024 13:54:25 -0700 Subject: [PATCH] [zookeeper] remove backports for releases older than oldstable oldoldstable backports have been moved to archive ; attempting to fetch the release data will result in init action failure. --- zookeeper/zookeeper.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/zookeeper/zookeeper.sh b/zookeeper/zookeeper.sh index 8236f5ed8..5fd0554c9 100755 --- a/zookeeper/zookeeper.sh +++ b/zookeeper/zookeeper.sh @@ -19,6 +19,25 @@ readonly NOT_SUPPORTED_MESSAGE="Zookeeper initialization action is not supported Use Zookeeper Component instead: https://cloud.google.com/dataproc/docs/concepts/components/zookeeper" [[ $DATAPROC_VERSION != 1.* ]] && echo "$NOT_SUPPORTED_MESSAGE" && exit 1 +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 retry_apt_command() { cmd="$1" for ((i = 0; i < 10; i++)); do @@ -84,6 +103,12 @@ if (($NODE_NUMBER > 2)); then exit 0 fi +# Remove > oldstable debian backports +if [[ ${OS_NAME} == debian ]] && + [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then + remove_old_backports +fi + # Download and extract ZooKeeper Server update_apt_get install_apt_get zookeeper-server