@@ -54,6 +54,7 @@ function download_file_from_url() {
5454# Function to safely remove temporary files and temporary download dir
5555# Argument is optional exit value to propagate it after cleanup
5656function cleanup_and_exit() {
57+ echo " ===== Cleaning up and exiting ====="
5758 local exit_val=$1
5859 if [ -z " ${DWN_DIR} " ]; then
5960 echo " cleanup_and_exit(): Temp download dir not provided !" >&2
@@ -63,16 +64,15 @@ function cleanup_and_exit() {
6364 PELORUS_TMP_DIR=$( basename " ${DWN_DIR} " )
6465 if [[ " ${PELORUS_TMP_DIR} " =~ " ${TMP_DIR_PREFIX} " * ]]; then
6566 echo " Cleaning up temporary files"
66- eval rm -f " ${DWN_DIR} /*"
67- rmdir " ${DWN_DIR} "
67+ rm -rf " ${DWN_DIR} "
6868 fi
6969 fi
7070 fi
71- # Show logs from pods which are in CrashLoopBackOff state
72- for failing_pod in $( oc get pods -n " ${PELORUS_NAMESPACE} " | grep -i crash | cut -d ' ' -f1 ) ;
73- do
74- echo " Logs from crashed pod: ${failing_pod} "
75- oc logs -n " ${PELORUS_NAMESPACE} " " ${failing_pod } "
71+ # Show logs from all pods.
72+ echo " ===== Pod Logs ===== "
73+ for pod in $( oc get pods -n " ${PELORUS_NAMESPACE} " -o name ) ; do
74+ echo " ----- Logs from ${pod} ----- "
75+ oc logs -n " ${PELORUS_NAMESPACE} " --all-containers " ${pod } "
7676 done
7777
7878 # Cleanup binary builds
@@ -96,7 +96,7 @@ function retry() {
9696}
9797
9898function print_help() {
99- printf " \nUsage: %s [OPTION]... -d [DIR]\n\n" % " $0 "
99+ printf " \nUsage: %s [OPTION]... -d [DIR]\n\n" " $0 "
100100 printf " \tStartup:\n"
101101 printf " \t -h\tprint this help\n"
102102 printf " \n\tOptions:\n"
191191
192192
193193# ## MAIN
194+
195+ echo " ===== 1. Set up deployment ====="
196+
194197# Create download directory
195198DWN_DIR=$( TMPDIR=" ${VENV} " mktemp -d -t " ${TMP_DIR_PREFIX} XXXXX" ) || exit 2
196199
@@ -479,6 +482,8 @@ if [ "${ENABLE_JIRA_CUSTOM_FAIL_EXP}" == true ]; then
479482 fi
480483fi
481484
485+ echo " ===== 2. Set up OpenShift resources ====="
486+
482487# We do check for the exit status, as we are not really interested in the
483488# current state, e.g. Active of that namespace before deleting resources.
484489if oc get namespace mongo-persistent 2> /dev/null; then
@@ -527,16 +532,16 @@ retry 5m 5s ogns prometheus-pelorus
527532cat " ${DWN_DIR} /ci_values.yaml"
528533
529534# Thanos and s3 support
530- THANOS_HELM_FLAG=" "
535+ THANOS_HELM_FLAG=() # an array so expanding it later will be 0 words if empty
531536if [ " ${ENABLE_THANOS} " == true ]; then
532537 echo " Enabling Thanos support"
533538 thanos_config_file=$( create_s3_thanos_config s3_host s3_bucket s3_access_key s3_secret_key)
534- THANOS_HELM_FLAG=" --values ${thanos_config_file} "
535- echo " ${THANOS_HELM_FLAG} "
539+ THANOS_HELM_FLAG=(" --values" " ${thanos_config_file} " )
536540fi
537541
538542# update exporter values and helm upgrade
539- eval helm upgrade pelorus charts/pelorus --namespace pelorus --values " ${DWN_DIR} /ci_values.yaml" " ${THANOS_HELM_FLAG} "
543+ echo helm upgrade pelorus charts/pelorus --namespace pelorus --values " ${DWN_DIR} /ci_values.yaml" " ${THANOS_HELM_FLAG[@]} "
544+ helm upgrade pelorus charts/pelorus --namespace pelorus --values " ${DWN_DIR} /ci_values.yaml" " ${THANOS_HELM_FLAG[@]} "
540545
541546retry 10m 5s owpr deploytime
542547retry 10m 5s owpr committime
@@ -547,15 +552,31 @@ retry 2m 5s oc wait pod --for=condition=Ready -n mongo-persistent -l app=mongo
547552retry 10m 10s oc wait pod --for=condition=Ready -n mongo-persistent -l app=todolist
548553
549554# Test all deployed exporters
555+
556+ echo " ===== 3. Test Exporters ====="
557+
558+ any_exporter_failed=" "
550559exporters=$( oc get route -n " ${PELORUS_NAMESPACE} " | grep " -exporter" )
551560echo " $exporters "
552561for exporter_route in $( echo " $exporters " | awk ' {print $2}' ) ;
553562do
554563 echo " $exporter_route "
555- curl " $exporter_route "
556- curl " $exporter_route " 2>&1 | grep todolist || exit 2
564+ route_output=" $( curl " $exporter_route " ) "
565+ curl_result=$?
566+ echo " $route_output "
567+ if [[ $curl_result -ne 0 ]]; then
568+ echo " Error curling $exporter_route " 1>&2
569+ any_exporter_failed=true
570+ elif ! { echo " $route_output " | grep todolist; }; then
571+ echo " todolist not found in $exporter_route " 1>&2
572+ any_exporter_failed=true
573+ fi
557574done
558575
576+ if [[ " $any_exporter_failed " = " true" ]]; then
577+ exit 2
578+ fi
579+
559580if oc get pods -n pelorus | grep -q Crash ; then
560581 echo " Some pods are not functioning properly"
561582 oc get pods -n pelorus
0 commit comments