From dcb30a8489f82034134cb27f3c6a9ea688c62ef9 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 7 Sep 2018 08:56:43 -0700 Subject: [PATCH] Delete leader node first --- net/gce.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net/gce.sh b/net/gce.sh index dad7a6d42..7fc60b889 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -187,13 +187,19 @@ case $command in delete) $metricsWriteDatapoint "testnet-deploy net-delete-begin=1" - gcloud_FindInstances "name~^$prefix-" + # Delete the leader node first to prevent unusual metrics on the dashboard + # during shutdown. + # TODO: It would be better to fully cut-off metrics reporting before any + # instances are deleted. + for filter in "^$prefix-leader" "^$prefix-"; do + gcloud_FindInstances "name~$filter" - if [[ ${#instances[@]} -eq 0 ]]; then - echo "No instances found matching '^$prefix-'" - else - gcloud_DeleteInstances "$yes" - fi + if [[ ${#instances[@]} -eq 0 ]]; then + echo "No instances found matching '$filter'" + else + gcloud_DeleteInstances "$yes" + fi + done rm -f "$configFile" $metricsWriteDatapoint "testnet-deploy net-delete-complete=1"