Change playground deletion lifespan to 10 days (#7970)

* Change playground deletion lifespan to 10 days

* user debug
This commit is contained in:
Ben Broderick Phillips 2024-03-30 02:22:16 -04:00 коммит произвёл GitHub
Родитель 7413b06c38
Коммит c8a76c18ee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -44,7 +44,7 @@ If you need the group for a little more time, add/update a tag named `DeleteAfte
*To create long-lived resources:*
NOTE: Resource groups in the playground subscription, if compliant and marked with valid aliases (see below), **will still
be marked for deletion after 30 days.** See the below examples for how to extend this deletion deadline if necessary.
be marked for deletion after 10 days.** See the below examples for how to extend this deletion deadline if necessary.
Create a resource group to contain all testing resources. The resource group name should start with your Microsoft alias.
Valid group name examples: `myalias`, `myalias-feature-101-testing`. Your Microsoft account must be

Просмотреть файл

@ -31,7 +31,7 @@ parameters:
- DisplayName: AzureCloud Playground - Resource Cleanup
SubscriptionConfigurations:
- $(sub-config-azure-cloud-playground)
AdditionalParameters: "-DeleteNonCompliantGroups -DeleteArmDeployments -MaxLifespanDeleteAfterHours 720"
AdditionalParameters: "-DeleteNonCompliantGroups -DeleteArmDeployments -MaxLifespanDeleteAfterHours 240"
# TODO: Disabled this clean-up as the dogfood enviroment is busted and the tests are no longer running
# see https://github.com/Azure/azure-sdk-for-python/pull/33483 were the tests were disabled.
# - DisplayName: Dogfood Translation - Resource Cleanup

Просмотреть файл

@ -173,14 +173,15 @@ function AddGithubUsersToAliasCache() {
Write-Error "Failed to retrieve github -> microsoft alias mappings from opensource api."
exit 1
}
Write-Host "Found $($users.Count) users"
foreach ($user in $users) {
if ($user.aad.alias) {
if ($user -and $user.aad.alias) {
$OwnerAliasCache[$user.aad.alias] = $true
}
if ($user.aad.userPrincipalName) {
if ($user -and $user.aad.userPrincipalName) {
$OwnerAliasCache[$user.aad.userPrincipalName] = $true
}
if ($user.github.login) {
if ($user -and $user.github.login) {
$OwnerAliasCache[$user.github.login] = $true
}
}
@ -334,11 +335,14 @@ function HasDeleteLock([object]$ResourceGroup) {
}
function DeleteArmDeployments([object]$ResourceGroup) {
if (!$DeleteArmDeployments) {
if (!$DeleteArmDeployments -or !$ResourceGroup) {
return
}
$toDelete = @(Get-AzResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName `
| Where-Object { $_ -and ($_.Outputs?.Count -or $_.Parameters?.ContainsKey('testApplicationSecret')) })
$toDelete = @()
try {
$toDelete = @(Get-AzResourceGroupDeployment -ResourceGroupName $ResourceGroup.ResourceGroupName `
| Where-Object { $_ -and ($_.Outputs?.Count -or $_.Parameters?.ContainsKey('testApplicationSecret')) })
} catch {}
if (!$toDelete -or !$toDelete.Count) {
return
}