From 228e1e76fdc7197a1f00a00f7f922bb4fd7d0759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= <66256922+daniel-weisse@users.noreply.github.com> Date: Mon, 12 May 2025 11:24:11 +0200 Subject: [PATCH] ci: dont fail if Azure resources were already deleted (#3827) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: dont fail if Azure resources were already deleted * ci: fix error assignement --------- Signed-off-by: Daniel Weiße --- .../e2e_cleanup_timeframe/e2e-cleanup.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh index d6d0365cb..0796ae1a0 100755 --- a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh +++ b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh @@ -15,6 +15,14 @@ function download_tfstate_artifact { function delete_terraform_resources { delete_err=0 if pushd "${1}/${2}"; then + # Workaround for cleaning up Azure resources + # We include a data source that is only used to generate output + # If this data source is deleted before we call terraform destroy, + # terraform will first try to evaluate the data source and fail, + # causing the destroy to fail as well. + sed -i '/data "azurerm_user_assigned_identity" "uaid" {/,/}/d' main.tf + sed -i '/output "user_assigned_identity_client_id" {/,/}/d' outputs.tf + terraform init > /dev/null || delete_err=1 # first, install plugins terraform destroy -auto-approve || delete_err=1 popd || exit 1 @@ -79,9 +87,15 @@ echo "[*] deleting resources" error_occurred=0 for directory in ./terraform-state-*; do echo " deleting resources in ${directory}" - delete_terraform_resources "${directory}" "constellation-terraform" || echo "[!] deleting resources failed" && error_occurred=1 + if ! delete_terraform_resources "${directory}" "constellation-terraform"; then + echo "[!] deleting resources failed" + error_occurred=1 + fi echo " deleting IAM configuration in ${directory}" - delete_terraform_resources "${directory}" "constellation-iam-terraform" || echo "[!] deleting IAM resources failed" && error_occurred=1 + if ! delete_terraform_resources "${directory}" "constellation-iam-terraform"; then + echo "[!] deleting IAM resources failed" + error_occurred=1 + fi echo " deleting directory ${directory}" rm -rf "${directory}" done