Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out future purge dates resources #1910

Merged
merged 1 commit into from
Aug 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions eng/scripts/live-test-resource-cleanup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ Write-Host "Count $($hasDeleteAfter.Count)"
$toDelete = $hasDeleteAfter.Where({ $deleteDate = ($_.Tags.DeleteAfter -as [DateTime]); (!$deleteDate -or $now -gt $deleteDate) })
Write-Host "Groups to delete: $($toDelete.Count)"

# Get purgeable resources already in a deleted state coerced into a collection even if empty.
$purgeableResources = Get-PurgeableResources
$purgeableResources = @()

foreach ($rg in $toDelete)
{
Expand All @@ -86,6 +85,16 @@ foreach ($rg in $toDelete)
}
}

# Get purgeable resources already in a deleted state coerced into a collection even if empty.
$purgeableResources = Get-PurgeableResources
$allPurgeCount = $purgeableResources.Count

# Filter down to the ones that we can actually perge.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"purge"

/cc @weshaggard

$purgeableResources = $purgeableResources.Where({ $purgeDate = $_.ScheduledPurgeDate -as [DateTime]; (!$purgeDate -or $now -gt $purgeDate) })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now how you filter them. You need to check EnableSoftDelete. You've also not purged the vaults early enough. The default is 90d, so you're effectively leaving hundreds of vaults un-purged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point in purging vaults in the future. Once the purge date is hit, they are purged automatically.


# Purge all the purgeable resources.
Write-Host "Deleting $($purgeableResources.Count) purgeable resources"
Write-Host "Attempting to purge $($purgeableResources.Count) resources."
if ($allPurgeCount -gt $purgeableResources.Count) {
Write-Host "Skipping $($allPurgeCount - $purgeableResources.Count) as their purge date is still in the future."
}
Remove-PurgeableResources $purgeableResources