forked from Fediversity/Fediversity
Report errors in subprocesses
This commit is contained in:
parent
0c75a4053e
commit
cbed66c934
2 changed files with 31 additions and 2 deletions
|
@ -366,7 +366,20 @@ provision_vm () (
|
||||||
for vm_name in $vm_names; do
|
for vm_name in $vm_names; do
|
||||||
provision_vm "$vm_name" &
|
provision_vm "$vm_name" &
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
nb_errors=0
|
||||||
|
while :; do
|
||||||
|
wait -n && :
|
||||||
|
case $? in
|
||||||
|
0) ;;
|
||||||
|
127) break ;;
|
||||||
|
*) nb_errors=$((nb_errors + 1)) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ "$nb_errors" != 0 ]; then
|
||||||
|
die 'encountered %d errors while provisioning VMs%s.' "$nb_errors" "$vm_names"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
printf 'done provisioning VMs%s.\n' "$vm_names"
|
printf 'done provisioning VMs%s.\n' "$vm_names"
|
||||||
|
|
||||||
|
@ -374,3 +387,4 @@ printf 'done provisioning VMs%s.\n' "$vm_names"
|
||||||
## Cleanup
|
## Cleanup
|
||||||
|
|
||||||
rm -Rf $tmpdir
|
rm -Rf $tmpdir
|
||||||
|
exit 0
|
||||||
|
|
|
@ -112,6 +112,7 @@ proxmox () {
|
||||||
}
|
}
|
||||||
|
|
||||||
## Way to inject different behaviour on unexpected status.
|
## Way to inject different behaviour on unexpected status.
|
||||||
|
# shellcheck disable=SC2317
|
||||||
default_proxmox_sync_unexpected_status_handler () {
|
default_proxmox_sync_unexpected_status_handler () {
|
||||||
die "unexpected status: '%s'" "$1"
|
die "unexpected status: '%s'" "$1"
|
||||||
}
|
}
|
||||||
|
@ -194,6 +195,7 @@ stop_vm () {
|
||||||
################################################################################
|
################################################################################
|
||||||
## Delete VM
|
## Delete VM
|
||||||
|
|
||||||
|
# shellcheck disable=SC2317
|
||||||
proxmox_sync_unexpected_status_handler_ignore_null () {
|
proxmox_sync_unexpected_status_handler_ignore_null () {
|
||||||
case $1 in
|
case $1 in
|
||||||
null)
|
null)
|
||||||
|
@ -233,7 +235,19 @@ remove_vm () (
|
||||||
for vm_id_or_name in $vm_ids_or_names; do
|
for vm_id_or_name in $vm_ids_or_names; do
|
||||||
remove_vm "$vm_id_or_name" &
|
remove_vm "$vm_id_or_name" &
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
|
nb_errors=0
|
||||||
|
while :; do
|
||||||
|
wait -n && :
|
||||||
|
case $? in
|
||||||
|
0) ;;
|
||||||
|
127) break ;;
|
||||||
|
*) nb_errors=$((nb_errors + 1)) ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [ "$nb_errors" != 0 ]; then
|
||||||
|
die 'encountered %d errors while removing VMs%s.' "$nb_errors" "$vm_ids_or_names"
|
||||||
|
fi
|
||||||
|
|
||||||
printf 'done removing VMs%s.\n' "$vm_ids_or_names"
|
printf 'done removing VMs%s.\n' "$vm_ids_or_names"
|
||||||
|
|
||||||
|
@ -241,3 +255,4 @@ printf 'done removing VMs%s.\n' "$vm_ids_or_names"
|
||||||
## Cleanup
|
## Cleanup
|
||||||
|
|
||||||
rm -Rf $tmpdir
|
rm -Rf $tmpdir
|
||||||
|
exit 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue