|
| 1 | +function Is-CompartmentIdValid() { |
| 2 | + Write-Host "#===== Validating Compartment ID in Endpoint and Namespace =====#" |
| 3 | + Write-Host "" |
| 4 | + $eps = Get-HnsEndpoint |
| 5 | + $nss = Get-HnsNamespace |
| 6 | + |
| 7 | + foreach($ep in $eps) { |
| 8 | + if ($ep.Resources.Allocators.CompartmendId.Length -gt 0) { |
| 9 | + $compId = [int]$($ep.Resources.Allocators.CompartmendId[0]) |
| 10 | + $nsId = $ep.Namespace.ID |
| 11 | + foreach($ns in $nss) { |
| 12 | + if ($ns.ID -Eq $nsId) { |
| 13 | + Write-Host "IP Address : $($ep.IPAddress), NamespaceID: $nsId, EPCompID : $compId, NSCompID: $($ns.CompartmentId)" |
| 14 | + if ($ns.CompartmentId -NE $compId) { |
| 15 | + Write-Host "CompartmentId not matching..." |
| 16 | + return $false |
| 17 | + } else { |
| 18 | + Write-Host "CompartmentId matching..." |
| 19 | + } |
| 20 | + } |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + Write-Host "" |
| 25 | + return $true |
| 26 | +} |
| 27 | + |
| 28 | +$iter = 1 |
| 29 | +$curLoc = (Get-Location).Path |
| 30 | +pktmon stop # Stopping if pktmon is already running |
| 31 | + |
| 32 | +# Start pktmon |
| 33 | +Write-Host "#===== Starting pktmon with trace level 6 for TCPIP and Host-Network-Service =====#" |
| 34 | +pktmon start --trace -p Microsoft-Windows-TCPIP -k 0xFF -l 6 -p Microsoft-Windows-Host-Network-Service -l 6 -f traces.etl -s 2048 |
| 35 | + |
| 36 | + |
| 37 | +While(Is-CompartmentIdValid) { |
| 38 | + $d = Get-Date |
| 39 | + Write-Host "#===== Iteration: $iter completed at $d. No issue found. Waiting for 1 minute for next iteration. =====#" |
| 40 | + Write-Host "" |
| 41 | + Start-Sleep -Seconds 60 |
| 42 | + $iter++ |
| 43 | +} |
| 44 | + |
| 45 | +Write-Host "#===== Issue detected. Waiting for 1 minute before Stopping pktmon and collecting logs. =====#" |
| 46 | +Start-Sleep -Seconds 60 |
| 47 | +Write-Host "" |
| 48 | +# Stop pktmon |
| 49 | +pktmon stop |
| 50 | + |
| 51 | +# Collecting Windows logs |
| 52 | +C:\k\debug\collect-windows-logs.ps1 |
| 53 | + |
| 54 | +Write-Host "Traces available in $curLoc\traces.etl" |
| 55 | + |
| 56 | +# The below While loop will keep the script running indefinitely keeping the hpc pod alive. |
| 57 | +# Without this, the pod will exit after the script execution and restart the process again deleting the logs. |
| 58 | +While($true) { |
| 59 | + if ($iter -Eq 1) { |
| 60 | + Write-Host "The issue was detected on a previously corrupted node, and log rotation may have occurred." |
| 61 | + } else { |
| 62 | + Write-Host "Issue detected. Please download and review the collected Windows logs and also traces from the following path: $curLoc\traces.etl" |
| 63 | + } |
| 64 | + Start-Sleep -Seconds 3600 |
| 65 | +} |
0 commit comments