Skip to content

Commit

Permalink
Edit containerd snapshot size calculation (#4345)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiashok authored Jul 8, 2024
1 parent fd3ad31 commit 3f462e6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions staging/cse/windows/debug/collect-windows-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,25 @@ if ($enableAll -or $enableContainerdInfo) {
}

if ($enableAll -or $enableSnapshotSize) {
Write-Host "Collecting container snapshot size using DU tool"
if (Test-Path "C:\aks-tools\DU\du.exe") {
C:\aks-tools\DU\du.exe /accepteula
C:\aks-tools\DU\du.exe -l 1 C:\ProgramData\containerd\root\io.containerd.snapshotter.v1.windows\snapshots\ > "$ENV:TEMP\$timeStamp-du-snapshot-folder-size.txt"
$paths += "$ENV:TEMP\$timeStamp-du-snapshot-folder-size.txt"
Write-Host "Collecting actual size of snapshot (without sparse file sizes included)"

$snapshotPath = "C:\ProgramData\containerd\root\io.containerd.snapshotter.v1.windows\snapshots\"
$snapshotSizesResultFilePath = "$ENV:TEMP\$timeStamp-all-snapshot-folder-size.txt"
$listOfSnapshotFolders = Get-ChildItem $snapshotPath | Where-Object {$_.PSIsContainer -eq $true} | Sort-Object
$totalSize = 0
foreach ($i in $listOfSnapshotFolders) {
$folderSize = 0
Get-ChildItem -Path $i.FullName -recurse -Attributes !SparseFile | Where-Object {$_.PSIsContainer -eq $false} | ForEach-Object {
$folderSize = $folderSize + $_.Length
}
$output = "Sum of " + $i.FullName + " is " + ($folderSize/1MB) + "MB"
$totalSize = $totalSize + $folderSize
Add-Content -Path $snapshotSizesResultFilePath -Value $output
}
$outputTotalSize = "Total size of all snapshots: " + ($totalSize/1MB) + "MB"
Add-Content -Path $snapshotSizesResultFilePath -Value $outputTotalSize
$paths += $snapshotSizesResultFilePath

Copy-Item 'C:\ProgramData\containerd\root\io.containerd.snapshotter.v1.windows\metadata.db' "$ENV:TEMP\$timeStamp-snpashot-metadata.db"
$paths += "$ENV:TEMP\$timeStamp-snpashot-metadata.db"
} else {
Expand Down

0 comments on commit 3f462e6

Please sign in to comment.