Merge "Print logs if vm create will fail"
This commit is contained in:
commit
aba9111ab5
@ -14,6 +14,7 @@ usage() {
|
|||||||
-k Kubernetes namespace (optional)
|
-k Kubernetes namespace (optional)
|
||||||
-i Image to boot VMs from (optional, will upload Cirros if ommited)
|
-i Image to boot VMs from (optional, will upload Cirros if ommited)
|
||||||
-f Allocate floating IPs and associate with VMs (optional)
|
-f Allocate floating IPs and associate with VMs (optional)
|
||||||
|
-d Print debug to stdout
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +29,14 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
vm_error_logs() {
|
||||||
|
for v in `openstack server list -f value | awk '/ERROR/ { print $1 }'`; do
|
||||||
|
echo "-------------- ${f} ---------------"
|
||||||
|
set +e
|
||||||
|
kubectl --namespace "${K8S_NAMESPACE}" logs "${f}" | grep "${v}"
|
||||||
|
set -e
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
if [ -z "${NUMBER}" ]; then
|
if [ -z "${NUMBER}" ]; then
|
||||||
@ -49,22 +58,30 @@ create() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
openstack server list
|
openstack server list
|
||||||
|
if openstack server list | grep ERROR; then
|
||||||
|
echo "Error while creating vm"
|
||||||
|
if [ -n "${PRINT_STD}" ]; then
|
||||||
|
for f in `kubectl --namespace=${K8S_NAMESPACE} get pods -o go-template --template="{{ range .items }}{{ println .metadata.name}}{{end}}"`; do
|
||||||
|
vm_error_logs
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
for vm in $(openstack server list -f value -c Name | grep test_vm); do
|
for vm in $(openstack server list -f value -c Name | grep test_vm); do
|
||||||
echo "Console for $vm:"
|
echo "Console for ${vm}:"
|
||||||
openstack console url show $vm
|
openstack console url show "${vm}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
for vm in $(openstack server list -f value -c Name | grep test_vm); do
|
for vm in $(openstack server list -f value -c Name | grep test_vm); do
|
||||||
echo "Destroying $vm..."
|
echo "Destroying $vm..."
|
||||||
openstack server delete --wait $vm
|
openstack server delete --wait "${vm}"
|
||||||
done
|
done
|
||||||
echo "Destroying cirros image..."
|
echo "Destroying cirros image..."
|
||||||
openstack image delete cirros
|
openstack image delete cirros
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ":a:n:k:i:fh" opt; do
|
while getopts ":a:n:k:i:fhd" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
a)
|
a)
|
||||||
ACTION="$OPTARG"
|
ACTION="$OPTARG"
|
||||||
@ -81,6 +98,9 @@ while getopts ":a:n:k:i:fh" opt; do
|
|||||||
f)
|
f)
|
||||||
ADD_FLOATING="yes"
|
ADD_FLOATING="yes"
|
||||||
;;
|
;;
|
||||||
|
d)
|
||||||
|
PRINT_STD="yes"
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
@ -98,6 +118,11 @@ while getopts ":a:n:k:i:fh" opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -z "${K8S_NAMESPACE}" ] && [ -n "${PRINT_STD}"]; then
|
||||||
|
echo "To print debug to stdout you need to set K8S namespace with -k parameter"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$ACTION" ]; then
|
if [ -z "$ACTION" ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user