Repository navigation
[release/v7.4.15] Close pipe client handles after creating the child ssh process #27139
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
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 | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,3 +70,24 @@ Describe "SSHConnection parameter hashtable type conversions" -Tags 'Feature', ' | |||||||||||||||||||||||||||||||||||||||
| $err.FullyQualifiedErrorId | Should -Match 'PSSessionOpenFailed' | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Describe "No hangs when host doesn't exist" -Tags "CI" { | ||||||||||||||||||||||||||||||||||||||||
| $testCases = @( | ||||||||||||||||||||||||||||||||||||||||
| @{ | ||||||||||||||||||||||||||||||||||||||||
| Name = 'Verifies no hang for New-PSSession with non-existing host name' | ||||||||||||||||||||||||||||||||||||||||
| ScriptBlock = { New-PSSession -HostName "test-notexist" -UserName "test" -ErrorAction Stop } | ||||||||||||||||||||||||||||||||||||||||
| FullyQualifiedErrorId = 'PSSessionOpenFailed' | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| @{ | ||||||||||||||||||||||||||||||||||||||||
| Name = 'Verifies no hang for Invoke-Command with non-existing host name' | ||||||||||||||||||||||||||||||||||||||||
| ScriptBlock = { Invoke-Command -HostName "test-notexist" -UserName "test" -ScriptBlock { 1 } -ErrorAction Stop } | ||||||||||||||||||||||||||||||||||||||||
| FullyQualifiedErrorId = 'PSSessionStateBroken' | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| It "<Name>" -TestCases $testCases { | ||||||||||||||||||||||||||||||||||||||||
| param ($ScriptBlock, $FullyQualifiedErrorId) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| $ScriptBlock | Should -Throw -ErrorId $FullyQualifiedErrorId -ExceptionType 'System.Management.Automation.Remoting.PSRemotingTransportException' | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
| $ScriptBlock | Should -Throw -ErrorId $FullyQualifiedErrorId -ExceptionType 'System.Management.Automation.Remoting.PSRemotingTransportException' | |
| $timeoutSec = 60 | |
| $job = Start-Job -ScriptBlock $ScriptBlock | |
| try { | |
| $completedJob = $job | Wait-Job -Timeout $timeoutSec | |
| if (-not $completedJob) { | |
| Stop-Job -Job $job -ErrorAction SilentlyContinue | |
| Remove-Job -Job $job -Force -ErrorAction SilentlyContinue | |
| Set-ItResult -Failed -Because "Remoting call did not complete within $timeoutSec seconds. Potential hang when connecting to non-existing host." | |
| return | |
| } | |
| { Receive-Job -Job $job -ErrorAction Stop } | Should -Throw -ErrorId $FullyQualifiedErrorId -ExceptionType 'System.Management.Automation.Remoting.PSRemotingTransportException' | |
| } | |
| finally { | |
| if ($job -and $job.State -ne 'Closed') { | |
| Remove-Job -Job $job -Force -ErrorAction SilentlyContinue | |
| } | |
| } |
Copilot
AI
Apr 1, 2026
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.
This new CI Describe block doesn’t skip when ssh isn’t available, while other SSH remoting tests do (e.g. SSHRemotingAPI.Tests.ps1 uses a $skipTest guard). To avoid CI failures on images/environments without OpenSSH, add a similar skip condition (or explicitly assert the prerequisite and skip with a clear reason).
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.
test-notexistis not guaranteed to be non-resolvable (DNS search suffixes and wildcard DNS can resolve it), which can make this CI test flaky or slow. Use a reserved non-existent domain like*.invalid(RFC 2606) and/or pass a small-ConnectingTimeoutto keep the test deterministic.