Bumped runner version and added download_with_retries
We not only need to bump the runner, but also apparently the
"download_with_retries" was removed in the runnner AMI for
some mysterious reasons
diff --git a/github-runner-ami/packer/files/git.sh b/github-runner-ami/packer/files/git.sh
index 1499c9e..10cb2df 100644
--- a/github-runner-ami/packer/files/git.sh
+++ b/github-runner-ami/packer/files/git.sh
@@ -19,6 +19,45 @@
GIT_REPO="ppa:git-core/ppa"
GIT_LFS_REPO="https://packagecloud.io/install/repositories/github/git-lfs"
+function download_with_retries() {
+# Due to restrictions of bash functions, positional arguments are used here.
+# In case if you using latest argument NAME, you should also set value to all previous parameters.
+# Example: download_with_retries $ANDROID_SDK_URL "." "android_sdk.zip"
+ local URL="$1"
+ local DEST="${2:-.}"
+ local NAME="${3:-${URL##*/}}"
+ local COMPRESSED="$4"
+
+ if [[ $COMPRESSED == "compressed" ]]; then
+ local COMMAND="curl $URL -4 -sL --compressed -o '$DEST/$NAME' -w '%{http_code}'"
+ else
+ local COMMAND="curl $URL -4 -sL -o '$DEST/$NAME' -w '%{http_code}'"
+ fi
+
+ echo "Downloading '$URL' to '${DEST}/${NAME}'..."
+ retries=20
+ interval=30
+ while [ $retries -gt 0 ]; do
+ ((retries--))
+ # Temporary disable exit on error to retry on non-zero exit code
+ set +e
+ http_code=$(eval $COMMAND)
+ exit_code=$?
+ if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then
+ echo "Download completed"
+ return 0
+ else
+ echo "Error — Either HTTP response code for '$URL' is wrong - '$http_code' or exit code is not 0 - '$exit_code'. Waiting $interval seconds before the next attempt, $retries attempts left"
+ sleep $interval
+ fi
+ # Enable exit on error back
+ set -e
+ done
+
+ echo "Could not download $URL"
+ return 1
+}
+
## Install git
add-apt-repository $GIT_REPO -y
apt-get update
diff --git a/github-runner-ami/packer/vars/variables.pkrvars.hcl b/github-runner-ami/packer/vars/variables.pkrvars.hcl
index 66547db..75f67f8 100644
--- a/github-runner-ami/packer/vars/variables.pkrvars.hcl
+++ b/github-runner-ami/packer/vars/variables.pkrvars.hcl
@@ -19,5 +19,5 @@
ami_name = "airflow-runner-ami"
aws_regions = ["eu-central-1", "us-east-2"]
packer_role_arn = "arn:aws:iam::827901512104:role/packer-role"
-runner_version = "2.302.1-airflow1"
+runner_version = "2.303.0-airflow3"
session_manager_instance_profile_name = "packer_ssm_instance_profile"