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