From a04b215bcc4f63e85554ac6fd3a251f6c30c9d67 Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Fri, 2 Feb 2024 10:42:33 -0300 Subject: [PATCH] gha: delete azure RG only if it exists delete_cluster() has tried to delete the az resources group regardless if it exists. In some cases the result of that operation is ignored, i.e., fail to resource group not found, but the log messages get a little dirty. Let's delete the RG only if it exists then. Fixes #8989 Signed-off-by: Wainer dos Santos Moschetta --- tests/gha-run-k8s-common.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index 475ab4158..565b89272 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -104,10 +104,12 @@ function get_cluster_credentials() { function delete_cluster() { test_type="${1:-k8s}" + local rg + rg="$(_print_rg_name ${test_type})" - az group delete \ - -g "$(_print_rg_name ${test_type})" \ - --yes + if [ "$(az group exists -g "${rg}")" == "true" ]; then + az group delete -g "${rg}" --yes + fi } function delete_cluster_kcli() {