Skip to content

Commit

Permalink
Fix for bigtable.sh - Debian buster repo issue (#1164)
Browse files Browse the repository at this point in the history
* Fix for bigtable.sh - Debian backports repo issue.

* Fix for bigtable.sh - Debian backports repo issue.

* Fix for bigtable.sh - Debian backports repo issue.
Added condition to consider 2.1 Dataproc image version for debian as suggsted by the reviewers

* Added missing OS_NAME variable
  • Loading branch information
kuldeepkk-dev committed Apr 19, 2024
1 parent 18acb1a commit 0985c2e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bigtable/bigtable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -euxo pipefail
# Use Python from /usr/bin instead of /opt/conda.
export PATH=/usr/bin:$PATH

readonly OS_NAME=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

# Detect dataproc image version from its various names
Expand Down Expand Up @@ -56,6 +57,24 @@ fi
readonly BIGTABLE_PROJECT="$(/usr/share/google/get_metadata_value attributes/bigtable-project ||
/usr/share/google/get_metadata_value ../project/project-id)"

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_command() {
local -r cmd="${1}"
for ((i = 0; i < 10; i++)); do
Expand Down Expand Up @@ -243,6 +262,9 @@ function install_hbase() {
}

function main() {
if [[ ${OS_NAME} == debian ]] && [[ $(echo "${DATAPROC_IMAGE_VERSION} <= 2.1" | bc -l) == 1 ]]; then
remove_old_backports
fi
install_hbase || err 'Failed to install HBase.'
install_bigtable_client || err 'Unable to install big table client.'
install_shc || err 'Failed to install Spark-HBase connector.'
Expand Down

0 comments on commit 0985c2e

Please sign in to comment.