driver: Add verbose finity retries to the driver installation
VENDOR=rancher.io
DRIVER=longhorn
+RETRY_COUNTS=20
+RETRY_INTERVAL=1
+
# Assuming the single driver file is located at /$DRIVER inside the DaemonSet image.
echo Detecting backend service IP for $LONGHORN_BACKEND_SVC
LONGHORN_BACKEND_SVC_IP=""
-until echo ${LONGHORN_BACKEND_SVC_IP} | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" > /dev/null; do
+
+found=false
+for i in `seq 1 ${RETRY_COUNTS}`;
+do
LONGHORN_BACKEND_SVC_IP=`nslookup ${LONGHORN_BACKEND_SVC} | grep Address: | awk '{if(NR > 1) print $2}'`
- sleep 1
+ echo ${LONGHORN_BACKEND_SVC_IP} | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" > /dev/null
+ if [ $? -eq 0 ]
+ then
+ found=true
+ break
+ fi
+ echo Cannot detect valid service IP, retrying
+ sleep ${RETRY_INTERVAL}
done
+if [ "$found" == false ]
+then
+ echo Fail to detect valid service IP. Aborting
+ exit -1
+fi
+
echo Backend service IP for $LONGHORN_BACKEND_SVC is $LONGHORN_BACKEND_SVC_IP
sed -ri "s|^LONGHORN_SVC=.*|LONGHORN_SVC=\"${LONGHORN_BACKEND_SVC_IP}:9500\"|" "/${DRIVER}"
