gce.sh: Unwind allocation upon failure (#6343)

automerge
This commit is contained in:
Trent Nelson 2019-10-14 10:36:20 -06:00 committed by Grimes
parent 82fea9ce73
commit b75438ff32
1 changed files with 12 additions and 0 deletions

View File

@ -575,6 +575,14 @@ delete() {
$metricsWriteDatapoint "testnet-deploy net-delete-complete=1"
}
create_error_cleanup() {
declare RC=$?
if [[ "$RC" -ne 0 ]]; then
delete
fi
exit $RC
}
case $command in
delete)
delete
@ -587,6 +595,10 @@ create)
$metricsWriteDatapoint "testnet-deploy net-create-begin=1"
if $failOnValidatorBootupFailure; then
trap create_error_cleanup EXIT
fi
rm -rf "$sshPrivateKey"{,.pub}
# Note: using rsa because |aws ec2 import-key-pair| seems to fail for ecdsa