Skip to content

Commit

Permalink
Do not block job from running on runner hooks (#678)
Browse files Browse the repository at this point in the history
A softer approach to the job started hook checks that runs
systematically.
To avoid a situation where those hook might do more harm than good, if
they continuously fail after a certain amount of tries, release the
runner and let it do its thing.
  • Loading branch information
tcarmet authored Sep 12, 2024
1 parent 50efe19 commit e4e66df
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions runner_manager/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,29 @@ function job_started {
echo "Running preliminary checks..."
# Check if apt, dnf, or yum is running
echo "Ensure no package manager is running"
local tries=0
while pgrep -x "apt" >/dev/null || pgrep -x "dnf" >/dev/null || pgrep -x "yum" >/dev/null; do
echo "Waiting for package manager to finish"
sleep 5
((tries++))
sleep "${tries}"
if [[ ${tries} -eq 10 ]]; then
echo "::warning::Package manager did not finish"
break
fi
done

# reset tries counter
tries=0
if [[ ! ${LABELS} =~ "no-docker" ]]; then
echo "Ensure docker is running"
while ! docker info >/dev/null 2>&1; do
echo "Waiting for docker to start"
sleep 5
((tries++))
sleep "${tries}"
if [[ ${tries} -eq 10 ]]; then
echo "::warning::Docker did not start"
break
fi
done
fi
# Run bash injected through runner group config
Expand Down

0 comments on commit e4e66df

Please sign in to comment.