Skip to content

Commit

Permalink
fix: retry the jq installation in case of errors (#1033)
Browse files Browse the repository at this point in the history
## Description

In case of network connection problems, the `yum` operations ends with
an error. This PR adds a retry to install `jq`.

## Migrations required

NO

## Verification

Confirmed this works for my setup by vendoring this module with these
changes.

---------

Co-authored-by: Ryan Causey <ryan.causey@munipal.io>
Co-authored-by: Matthias Kay <matthias.kay@hlag.com>
Co-authored-by: Matthias Kay <github@matthiaskay.de>
  • Loading branch information
4 people committed Nov 13, 2023
1 parent b81103b commit 1ab5690
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 0 additions & 5 deletions template/gitlab-runner.tftpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Install jq if not exists
if ! [ -x "$(command -v jq)" ]; then
yum install jq -y
fi

# Provide the parent instance id in the spawned runner tags
PARENT_INSTANCE_ID=$(curl -s -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .instanceId)
PARENT_TAG="gitlab-runner-parent-id,$PARENT_INSTANCE_ID"
Expand Down
7 changes: 7 additions & 0 deletions template/yum_update.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ for i in {1..7}; do
echo "Attempt: ---- " $i
yum -y update && break || sleep 60
done

# Install additional programs needed by the scripts
for i in {1..7}
do
echo "Attempt: ---- " $i
yum install -y jq && break || sleep 60
done

0 comments on commit 1ab5690

Please sign in to comment.