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

[zookeeper] remove backports for releases older than oldstable #1170

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
25 changes: 25 additions & 0 deletions zookeeper/zookeeper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -84,6 +103,12 @@ if (($NODE_NUMBER > 2)); then
exit 0
fi

# Remove > oldstable debian backports
if [[ ${OS_NAME} == debian ]] &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OS_NAME is not declared and hence this script will fail

[[ $(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
Expand Down