From 52384101c2ec432a22217380e6ef7d8ccf530a1e Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Tue, 12 Sep 2023 16:58:55 -0400 Subject: [PATCH] Skip cleaning up locked resource groups (#6951) --- eng/scripts/live-test-resource-cleanup.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/eng/scripts/live-test-resource-cleanup.ps1 b/eng/scripts/live-test-resource-cleanup.ps1 index 79dcc37a728..502c044fa4e 100644 --- a/eng/scripts/live-test-resource-cleanup.ps1 +++ b/eng/scripts/live-test-resource-cleanup.ps1 @@ -309,7 +309,12 @@ function HasDoNotDeleteTag([object]$ResourceGroup) { return $doNotDelete -ne $null } -function HasDeleteLock() { +function HasDeleteLock([object]$ResourceGroup) { + $lock = Get-AzResourceLock -ResourceGroupName $ResourceGroup.ResourceGroupName + if ($lock) { + Write-Host " Skipping locked resource group '$($ResourceGroup.ResourceGroupName)'" + return $true + } return $false } @@ -347,7 +352,10 @@ function DeleteOrUpdateResourceGroups() { if (HasValidAliasInName $rg) { continue } - if (HasValidOwnerTag $rg -or HasDeleteLock $rg) { + if (HasValidOwnerTag $rg) { + continue + } + if (HasDeleteLock $rg) { continue } $toUpdate += $rg