Skip to content

Commit

Permalink
Improve pipeline start script logic
Browse files Browse the repository at this point in the history
Add timeout for the other while loop was needed to to hanging, when no
quay secret was present. Added logic to not search for quay secret if
the internal image registry is being used (eg.: RHDP)
  • Loading branch information
darkdoc committed Oct 7, 2024
1 parent 7926f39 commit 29e6e98
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions scripts/start_pipelines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ while [ ${ATTEMPT} -le ${MAX_ATTEMPTS} ]; do
else
echo "ClusterTasks not found yet"
if [ ${ATTEMPT} -ge ${MAX_ATTEMPTS} ]; then
echo "Max attempts reached. Existing."
echo "Max attempts reached. Exiting."
exit 1
fi
ATTEMPT=$((ATTEMPT + 1))
sleep ${DELAY}
Expand All @@ -25,9 +26,17 @@ done

echo "Checking for resources to be available to start pipelines"
retry=0
check=1
while [ "$check" == "1" ]; do
MAX_ATTEMPTS=720
DELAY=5
ATTEMPT=0

while [ ${ATTEMPT} -le ${MAX_ATTEMPTS} ]; do
sleep ${DELAY}
if [ ${ATTEMPT} -ge ${MAX_ATTEMPTS} ]; then
echo "Max attempts reached. Exiting."
exit 1
fi
ATTEMPT=$((ATTEMPT + 1))

for p in ${pipelines[@]}; do
oc get -n $build_ns pipeline $p 1>/dev/null 2>/dev/null
Expand All @@ -43,15 +52,20 @@ while [ "$check" == "1" ]; do
retry=0
continue
fi
imageRegistryType=$(yq .global.imageregistry.type values-global.yaml)

if [ $imageRegistryType == "openshift-internal" ]; then
#No need to check secret if the image registry type is openshift-internal
break
fi
oc get -n $build_ns secret quay-auth-secret 1>/dev/null 2>/dev/null
if [ "$?" != "0" ]; then
echo "Error with secret quay-auth-secret, checking again"
continue
fi

# Everything checks out, time to leave this look
check=0
# Everything checks out, time to leave this loop
break
done

echo "Resources are all present, starting pipelines now"
Expand Down

0 comments on commit 29e6e98

Please sign in to comment.