-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): tester/builder start race conditions (#10893)
- lock around builder install - reuse code in tester/builder
- Loading branch information
Showing
8 changed files
with
75 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set -eu | ||
# One-time config only on builder. | ||
if ! [ -f ~/maybe_exit_spot.sh ] ; then | ||
cp scripts/ci/maybe_exit_spot.sh ~/maybe_exit_spot.sh | ||
# Run maybe_exit_spot.sh every minute | ||
chmod +x ~/maybe_exit_spot.sh | ||
echo "* * * * * ~/maybe_exit_spot.sh" | crontab - | ||
echo "Configured instance exit cron job." | ||
else | ||
echo "Chron jobs already configured." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
#!/usr/bin/env bash | ||
set -u | ||
exit_code=254 | ||
ttl=$1 | ||
scripts/run_on_builder " | ||
set -eu; | ||
sudo shutdown -P $ttl; | ||
if ! [ -d ~/run-$RUN_ID ]; then | ||
mkdir -p ~/run-$RUN_ID; | ||
cd ~/run-$RUN_ID; | ||
git init >/dev/null 2>&1; | ||
git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; | ||
git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; | ||
git checkout FETCH_HEAD >/dev/null 2>&1; | ||
fi; | ||
cd ~/run-$RUN_ID; | ||
.github/ensure-builder/wrapper $DOCKERHUB_PASSWORD '$INPUT'; | ||
function clone { | ||
if ! [ -d ~/run-$RUN_ID ]; then | ||
mkdir -p ~/run-$RUN_ID; | ||
cd ~/run-$RUN_ID; | ||
git init >/dev/null 2>&1; | ||
git remote add origin https://github.com/aztecprotocol/aztec-packages >/dev/null 2>&1; | ||
git fetch --depth 1 origin $GIT_COMMIT >/dev/null 2>&1; | ||
git checkout FETCH_HEAD >/dev/null 2>&1; | ||
fi; | ||
} | ||
export RUN_ID GIT_COMMIT | ||
export -f clone | ||
flock /var/lock/clone.lock bash -c clone | ||
cd ~/run-$RUN_ID | ||
flock /var/lock/install.lock .github/ensure-builder/chron | ||
flock /var/lock/install.lock .github/ensure-builder/install $DOCKERHUB_PASSWORD | ||
ci3/aws_handle_evict 'set -eu; $INPUT' | ||
" | ||
exit_code=$? | ||
if [ $exit_code = 255 ]; then | ||
echo "Treating ssh termination as spot eviction."; | ||
echo "Treating ssh termination as spot eviction." | ||
exit_code=155 | ||
fi; | ||
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT; | ||
fi | ||
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT | ||
if [ $exit_code = 155 ]; then | ||
echo "Spot eviction detected - retrying with on-demand." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -u # not -e | ||
[ "${BUILD_SYSTEM_DEBUG:-}" = 1 ] && set -x | ||
|
||
if [ -n "${RETRY_DISABLED:-}" ]; then | ||
set -e | ||
eval "$" | ||
exit | ||
fi | ||
|
||
ATTEMPTS=3 | ||
# Retries up to 3 times with 5 second intervals | ||
for i in $(seq 1 $ATTEMPTS); do | ||
eval "$*" && exit | ||
[ "$i" != "$ATTEMPTS" ] && sleep 5 | ||
done | ||
|
||
>&2 echo "$@ failed after $ATTEMPTS attempts" | ||
exit 1 |