Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 1b4597b

Browse files
jkruse14npalm
andauthored
fix: add retry logic to runner start script for libicu download (#3748)
## Background --- There seems to be a race condition some where with the user-data script and the EC2 starting up and locking RPM. This issue is seen elsewhere, not necessarily with this repo's user-data, see the following: [Amazon Linux 2023 - issue with installing packages with cloud-init](https://repost.aws/questions/QU_tj7NQl6ReKoG53zzEqYOw/amazon-linux-2023-issue-with-installing-packages-with-cloud-init) [dnf/yum both fails while being executed on instance bootstrap on Amazon Linux 2023](https://repost.aws/questions/QUgNz4VGCFSC2TYekM-6GiDQ/dnf-yum-both-fails-while-being-executed-on-instance-bootstrap-on-amazon-linux-2023) Also, #3741 ## Changes Made --- Added a loop to retry if the rpm lock file is found which sleeps for 5 seconds then retries again with a total of 5 iterations. ## Testing --- Spun up an instance and ran the script directly (using sudo the second time because this was not run via user-data) <img width="339" alt="image" src="https://github.com/philips-labs/terraform-aws-github-runner/assets/16331726/33679c00-b092-4900-80fd-838bb6c31409"> --------- Co-authored-by: Niek Palm <[email protected]>
1 parent 5fd1973 commit 1b4597b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: modules/runners/templates/install-runner.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,20 @@ echo OS: $os_id
4747

4848
# Install libicu on non-ubuntu
4949
if [[ ! "$os_id" =~ ^ubuntu.* ]]; then
50-
dnf install -y libicu
50+
max_attempts=5
51+
attempt_count=0
52+
success=false
53+
while [ $success = false ] && [ $attempt_count -le $max_attempts ]; do
54+
echo "Attempt $attempt_count/$max_attempts: Installing libicu"
55+
dnf install -y libicu
56+
if [ $? -eq 0 ]; then
57+
success=true
58+
else
59+
echo "Failed to install libicu"
60+
attempt_count=$(( attempt_count + 1 ))
61+
sleep 5
62+
fi
63+
done
5164
fi
5265

5366
# Install dependencies for ubuntu

0 commit comments

Comments
 (0)