From fc6ffb6cc4a8e3b16216f2f5c8518ed53b17e060 Mon Sep 17 00:00:00 2001 From: Artur Zarzycki Date: Wed, 30 Nov 2016 09:41:45 +0100 Subject: [PATCH] Timeout for deploying and output logs if fail Change-Id: I3f0996033d2479ec4593285a2bded1578ecab6a3 --- tools/ccp-multi-deploy/ccp-multi-deploy.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/ccp-multi-deploy/ccp-multi-deploy.sh b/tools/ccp-multi-deploy/ccp-multi-deploy.sh index 1ce8b37b..4e0fbef1 100755 --- a/tools/ccp-multi-deploy/ccp-multi-deploy.sh +++ b/tools/ccp-multi-deploy/ccp-multi-deploy.sh @@ -31,14 +31,28 @@ Options: (rely on existing local registry, default: false) -v, --openstack-version=VERSION set openstack version newton or master (default: master) +-d, --debug-std + print debug logs to standard output EOF exit } function ccp_wait_for_deployment_to_finish { + cnt=0 until [[ `${CCP} status -s -f value -c status` == "ok" ]]; do echo "Waiting for OpenStack deployment to finish..." sleep 5 + cnt=$((cnt + 1)) + if [ ${cnt} -eq 180 ]; then + echo "Max time exceeded" + if [ -n "${PRINT_STD}" ]; then + for f in `kubectl --namespace $1 get pod | grep -v -E '(Running|ContainerCreating|Pending)' | awk {'print $1'} | tail -n +2`; do + echo "-------------- ${f} ---------------" + kubectl --namespace "${1}" logs "${f}" + done + fi + exit 1 + fi done echo "...................................." echo "Jobs and pods in namespace: $1" @@ -62,7 +76,7 @@ function run_openstack_tests { # Parse command line arguments: -OPTS=`getopt -o 'hsn:v:' --long help,skip-building-images,number-of-envs:,openstack-version: -n 'parse-options' -- ${@}` +OPTS=`getopt -o 'hdsn:v:' --long help,debug-std,skip-building-images,number-of-envs:,openstack-version: -n 'parse-options' -- ${@}` if [ ${?} != 0 ] ; then echo "Failed parsing options." exit 1 @@ -75,6 +89,7 @@ while true; do -n|--number-of-envs ) NUMBER_OF_ENVS=${2}; shift; shift ;; -s|--skip-building-images ) BUILD_IMAGES=false; shift ;; -v|--openstack-version ) VERSION="${2}"; NAMESPACE_PREFIX="ccp-${2}"; shift; shift ;; + -d|--debug-std ) PRINT_STD="yes"; shift ;; -- ) shift; break ;; * ) break ;; esac