Skip to content

Commit

Permalink
chore: ebs attach robustness (#6108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad authored Apr 30, 2024
1 parent c985c73 commit c702688
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/setup-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ jobs:
run: |
# Compare the checked-out CI configuration files with the reference files
if ! git diff --no-index .github/workflows/ci.yml merge-commit-pipeline-files/.github/workflows/ci.yml; then
echo "Error: ci.yml changes in master (or PR base). Please merge these changes."
echo "Error: ci.yml changes in master (or PR base). Please merge these changes. This is to prevent surprises from Github Action's merge behavior."
exit 1
fi
if ! git diff --no-index .github/workflows/setup-runner.yml merge-commit-pipeline-files/.github/workflows/setup-runner.yml; then
echo "Error: setup-runner.yml changes in master (or PR base). Please merge these changes."
echo "Error: setup-runner.yml changes in master (or PR base). Please merge these changes. This is to prevent surprises from Github Action's merge behavior."
exit 1
fi
Expand Down
14 changes: 13 additions & 1 deletion scripts/attach_ebs_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@ if [ -f /run/.ebs-cache-mounted ] ; then
WAIT_INTERVAL=10 # Interval between checks in seconds
elapsed_time=0
# Check for existing mount, assume we can continue if existing

while ! mount | grep -q "/var/lib/docker type ext4"; do
echo "Someone already marked as mounting, waiting for them..."
echo "Someone already marked as mounting, terminating any stopped instances and waiting..."
# Identify and terminate instances in 'STOPPED' state that are using this volume
STOPPED_INSTANCES=$(aws ec2 describe-instances \
--region $REGION \
--filters "Name=instance-state-name,Values=stopped" "Name=block-device-mapping.volume-id,Values=$VOLUME_ID" \
--query "Reservations[*].Instances[*].InstanceId" \
--output text)

for instance in $STOPPED_INSTANCES; do
echo "Terminating instance $instance"
aws ec2 terminate-instances --instance-ids $instance
done
if [ $elapsed_time -ge $MAX_WAIT_TIME ]; then
echo "Cache mount did not become available within $MAX_WAIT_TIME seconds... race condition?"
exit 1
Expand Down

0 comments on commit c702688

Please sign in to comment.