Properly exit if kubevirt does not get ready on cluster-sync
cluster_dump can return a non-0 exit code. If it did so, it prevented
the script from exiting the wait loop for the kubevir-operator, leading
to endless waits.
Now we use pipefail and a trap to dump the cluster-state.
# Copyright 2018 Red Hat, Inc.
#
-set -ex
+set -ex pipefail
DOCKER_TAG=${DOCKER_TAG:-devel}
@@ -26,10 +26,14 @@ source cluster-up/cluster/$KUBEVIRT_PROVIDER/provider.sh
source hack/config.sh
function dump_kubevirt() {
+ if [ "$?" -ne "0" ]; then
echo "Dump kubevirt state:"
hack/dump.sh
+ fi
}
+trap dump_kubevirt EXIT
+
echo "Deploying ..."
# Create the installation namespace if it does not exist already
@@ -119,7 +123,7 @@ done
# Wait until KubeVirt is ready
count=0
until _kubectl wait -n kubevirt kv kubevirt --for condition=Available --timeout 5m; do
- ((count++)) && ((count == 5)) && echo "KubeVirt not ready in time" && dump_kubevirt && exit 1
+ ((count++)) && ((count == 5)) && echo "KubeVirt not ready in time" && exit 1
echo "Error waiting for KubeVirt to be Available, sleeping 1m and retrying"
sleep 1m
done
