Skip to content

Commit 2c35d2e

Browse files
Handle PowerShell native ssh stderr in smoke probes
1 parent 22fb505 commit 2c35d2e

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

docs/exec-plans/active/EP-001-portable-coder-foundation-and-multi-provider-mvp.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Initial user target providers/tools:
4747
- [x] (2026-02-20) Increase VM SSH readiness timeouts and diagnostics for slow first-boot cloud images
4848
- [x] (2026-02-20) Fix Windows smoke SSH probe command invocation so readiness check validates `echo vm-ready` output correctly
4949
- [x] (2026-02-20) Update Windows smoke SSH probe to pass remote commands directly (avoids PowerShell stdin encoding edge cases)
50+
- [x] (2026-02-20) Normalize Windows PowerShell native `ssh` stderr handling so host-key warnings do not abort readiness probes
5051
- [ ] (2026-02-18) Document setup/runbook and close out EP-001
5152

5253
## Context and Orientation
@@ -129,6 +130,7 @@ Acceptance criteria for EP-001:
129130
- 2026-02-20: First boot SSH readiness on some hosts can exceed 120 seconds, so timeout windows need to be configurable and longer by default.
130131
- 2026-02-20: Passing `ssh ... bash -lc <script>` as split args can drop expected output semantics; piping script content to `bash -s` is safer for deterministic probing.
131132
- 2026-02-20: Piping probe scripts into native `ssh` from Windows PowerShell can hit stdin encoding edge cases; direct remote command args are more reliable.
133+
- 2026-02-20: In Windows PowerShell, native stderr can surface as terminating `ErrorRecord` when `$ErrorActionPreference='Stop'`, so probe wrappers must normalize stderr explicitly.
132134

133135
## Decision Log
134136
- 2026-02-18: Adopt harness-first planning model before implementation.

scripts/runtime/windows/smoke-check.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,36 @@ function Invoke-Ssh {
6969
$Script
7070
)
7171

72+
$previousErrorAction = $ErrorActionPreference
7273
try {
73-
$output = & $SshExe @args 2>&1
74+
# Native ssh writes host-key notices to stderr; keep stderr non-terminating for probe loops.
75+
$ErrorActionPreference = 'Continue'
76+
$rawOutput = & $SshExe @args 2>&1
77+
$exitCode = $LASTEXITCODE
78+
79+
$normalized = @()
80+
foreach ($entry in @($rawOutput)) {
81+
if ($null -eq $entry) {
82+
continue
83+
}
84+
if ($entry -is [System.Management.Automation.ErrorRecord]) {
85+
$normalized += $entry.ToString()
86+
} else {
87+
$normalized += [string]$entry
88+
}
89+
}
90+
7491
return @{
75-
status = $LASTEXITCODE
76-
output = [string]::Join("`n", $output)
92+
status = $exitCode
93+
output = [string]::Join("`n", $normalized)
7794
}
7895
} catch {
7996
return @{
8097
status = 1
8198
output = $_.Exception.Message
8299
}
100+
} finally {
101+
$ErrorActionPreference = $previousErrorAction
83102
}
84103
}
85104

0 commit comments

Comments
 (0)