From 96daa3c5cfb78387e506cce28da5a8380b8a07ef Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Thu, 14 Mar 2024 09:52:08 +0100 Subject: [PATCH] ci: refactor sitespeed login retry (#5347) --- .github/workflows/sitespeed.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sitespeed.yml b/.github/workflows/sitespeed.yml index b5d673be95..c7c9d159c4 100644 --- a/.github/workflows/sitespeed.yml +++ b/.github/workflows/sitespeed.yml @@ -32,9 +32,16 @@ jobs: interval: 500 - name: Login MAAS admin run: | - for i in {1..5}; do - export API_KEY=`sudo maas apikey --username=admin` - maas login admin http://localhost:5240/MAAS $API_KEY && break || sleep 10 + # Retry admin login up to 5 times with 10s intervals to account for delays in MAAS becoming fully operational + for attempt in {1..5}; do + export API_KEY=$(sudo maas apikey --username=admin) + if maas login admin http://localhost:5240/MAAS $API_KEY; then + echo "Login successful." + break + else + echo "Login attempt $attempt failed. Retrying in 10 seconds..." + sleep 10 + fi done - name: Wait for MAAS boot resources shell: bash