Skip to content

Commit 777a095

Browse files
committed
fix(setup): Add retry logic to post-setup
Troubleshooting the lab build failures, post setup is being executed within seconds after the nova install completes, which may be too fast. If I can confirm it's a race condition, we will want a more intelligent way to determine when cluster is ready before proceeding to post-setup. For now, just adding dumb retry logic to the openstack commands to see if that helps.
1 parent bd482ab commit 777a095

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

scripts/hyperconverged-lab.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,48 @@ echo "Installing OpenStack"
12571257
sudo /opt/genestack/bin/setup-openstack.sh
12581258
EOC
12591259

1260+
# Run Genestack post setup
1261+
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
1262+
set -e
1263+
sudo bash <<HERE
1264+
sudo /opt/genestack/bin/setup-openstack-rc.sh
1265+
source /opt/genestack/scripts/genestack.rc
1266+
1267+
# Function to retry openstack commands with backoff
1268+
retry_openstack_command() {
1269+
local cmd="\\\$1"
1270+
local description="\\\$2"
1271+
local retry_count=0
1272+
local max_retries=12 # 12 retries * 10 seconds = 2 minutes
1273+
1274+
while [ \\\$retry_count -lt \\\$max_retries ]; do
1275+
echo "Attempting: \\\$description"
1276+
if eval "\\\$cmd"; then
1277+
echo "\\\$description succeeded"
1278+
return 0
1279+
else
1280+
retry_count=\\\$((retry_count + 1))
1281+
echo "\\\$description failed (attempt \\\$retry_count/\\\$max_retries). Retrying in 10 seconds..."
1282+
if [ \\\$retry_count -eq \\\$max_retries ]; then
1283+
echo "\\\$description failed after \\\$max_retries attempts. Continuing anyway..."
1284+
return 1
1285+
fi
1286+
sleep 10
1287+
fi
1288+
done
1289+
}
1290+
1291+
# Create flavor with retry
1292+
retry_openstack_command "if ! openstack --os-cloud default flavor show ${LAB_NAME_PREFIX}-test; then openstack --os-cloud default flavor create ${LAB_NAME_PREFIX}-test --public --ram 2048 --disk 10 --vcpus 2; fi" "Flavor setup"
1293+
1294+
# Create network with retry
1295+
retry_openstack_command "if ! openstack --os-cloud default network show flat; then openstack --os-cloud default network create --share --availability-zone-hint az1 --external --provider-network-type flat --provider-physical-network physnet1 flat; fi" "Network setup"
1296+
1297+
# Create subnet with retry
1298+
retry_openstack_command "if ! openstack --os-cloud default subnet show flat_subnet; then openstack --os-cloud default subnet create --subnet-range 192.168.102.0/24 --gateway 192.168.102.1 --dns-nameserver 1.1.1.1 --allocation-pool start=192.168.102.100,end=192.168.102.109 --dhcp --network flat flat_subnet; fi" "Subnet setup"
1299+
HERE
1300+
EOC
1301+
12601302
# Extra operations...
12611303
install_k9s() {
12621304
echo "Installing k9s"

0 commit comments

Comments
 (0)