-
Notifications
You must be signed in to change notification settings - Fork 183
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
{ | ||
|
@@ -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. | ||
$purgeableResources = $purgeableResources.Where({ $purgeDate = $_.ScheduledPurgeDate -as [DateTime]; (!$purgeDate -or $now -gt $purgeDate) }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"purge"
/cc @weshaggard