Skip to content

Commit

Permalink
feat: add parameters for collect-windows-logs.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiqianTao committed Apr 21, 2024
1 parent 104b3a2 commit 558221b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions staging/cse/windows/debug/collect-windows-logs.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# NOTE: Please also update staging/cse/windows/provisioningscripts/loggenerator.ps1 when collecting new logs.
$ProgressPreference = "SilentlyContinue"

param (
[string[]]$Params
)

function CollectLogsFromDirectory {
Param(
[Parameter(Mandatory=$true)]
Expand Down Expand Up @@ -52,6 +56,10 @@ $outputLogFile = "$ENV:TEMP\collect-windows-logs-output.log"
Start-Transcript -Path $outputLogFile
$paths += $outputLogFile

if ($args.Count -gt 0) {
Write-Host "Script's args: $args"
}

Write-Host "Collecting logs for various Kubernetes components"
get-childitem c:\k\*.log* -Exclude $lockedFiles | Foreach-Object {
$paths += $_
Expand Down Expand Up @@ -217,14 +225,16 @@ else {
Write-Host "ctr.exe command not available"
}

# collect disk usage information
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"
if ($args.Count -gt 0 -and $args -contains "disk-usage") {
# collect disk usage information
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"
}
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"
}
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"

# log containers, pods and images the CRI plugin is aware of, and their state.
$res = Get-Command crictl.exe -ErrorAction SilentlyContinue
Expand Down

0 comments on commit 558221b

Please sign in to comment.