Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Openshift deploy_che.sh script to detect if project deletion is completed and new project successfully created. #8159

Merged
merged 5 commits into from
Jan 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions dockerfiles/init/modules/openshift/files/scripts/deploy_che.sh
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,40 @@ echo "done!"
echo -n "[CHE] Checking if project \"${CHE_OPENSHIFT_PROJECT}\" exists..."
if ! oc get project "${CHE_OPENSHIFT_PROJECT}" &> /dev/null; then

if [ "${COMMAND}" == "cleanup" ] || [ "${COMMAND}" == "rollupdate" ]; then echo "**ERROR** project doesn't exist. Aborting"; exit 1; fi
if [ "${OPENSHIFT_FLAVOR}" == "osio" ]; then echo "**ERROR** project doesn't exist on OSIO. Aborting"; exit 1; fi
if [ "${COMMAND}" == "cleanup" ] || [ "${COMMAND}" == "rollupdate" ]; then echo "**ERROR** project doesn't exist. Aborting"; exit 1; fi
if [ "${OPENSHIFT_FLAVOR}" == "osio" ]; then echo "**ERROR** project doesn't exist on OSIO. Aborting"; exit 1; fi

echo -n "Project does not exist...creating it..."
oc new-project "${CHE_OPENSHIFT_PROJECT}" &> /dev/null
fi
echo "done!"
# OpenShift will not get project but project still exists for a period after being deleted.
# The following will loop until it can create successfully.

echo -n "[CHE] Switching to \"${CHE_OPENSHIFT_PROJECT}\"..."
oc project "${CHE_OPENSHIFT_PROJECT}" &> /dev/null
echo "done!"
WAIT_FOR_PROJECT_TO_DELETE=true
WAIT_FOR_PROJECT_TO_DELETE_MESSAGE="Waiting for project to be deleted fully(~15 seconds)..."

echo "Project \"${CHE_OPENSHIFT_PROJECT}\" does not exist...trying to creating it."
DEPLOYMENT_TIMEOUT_SEC=120
POLLING_INTERVAL_SEC=2
timeout_in=$((POLLING_INTERVAL_SEC+DEPLOYMENT_TIMEOUT_SEC))
while $WAIT_FOR_PROJECT_TO_DELETE
do
{ # try
timeout_in=$((timeout_in-POLLING_INTERVAL_SEC))
if [ "$timeout_in" -le "0" ] ; then
echo "[CHE] **ERROR**: Timeout of $DEPLOYMENT_TIMEOUT_SEC waiting for project \"${CHE_OPENSHIFT_PROJECT}\" to be delete."
exit 1
fi
oc new-project "${CHE_OPENSHIFT_PROJECT}" &> /dev/null && \
WAIT_FOR_PROJECT_TO_DELETE=false # Only excutes if project creation is successfully
} || { # catch
echo -n $WAIT_FOR_PROJECT_TO_DELETE_MESSAGE
WAIT_FOR_PROJECT_TO_DELETE_MESSAGE="."
sleep $POLLING_INTERVAL_SEC
}
done
echo "Project \"${CHE_OPENSHIFT_PROJECT}\" creation done!"
else
echo "Project \"${CHE_OPENSHIFT_PROJECT}\" already exists. Please remove project before running this script."
exit 1
fi

# -------------------------------------------------------------
# Deploying secondary servers
Expand Down