Skip to content

Commit 0946260

Browse files
sebsotoopenshift-cherrypick-robot
authored andcommitted
Retry SSH server initialization
Attempts to fix an issue where Windows Server 2019 machines were not having a running SSH server due to network instability.
1 parent 91d90f0 commit 0946260

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/secrets/secrets.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,19 @@ func generateUserDataWithPubKey(platformType oconfig.PlatformType, pubKey string
8181
}
8282
}
8383
84-
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
84+
# This requires a network connection, which is not guaranteed at VM initialization. Retry to work around this.
85+
$attempt = 0
86+
$success = $false
87+
while (-not $success -and $attempt -lt 10) {
88+
try {
89+
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 -ErrorAction Stop
90+
$success = $true
91+
}
92+
catch {
93+
$attempt++
94+
Start-Sleep -Seconds 5
95+
}
96+
}
8597
$firewallRuleName = "ContainerLogsPort"
8698
$containerLogsPort = "10250"
8799
New-NetFirewallRule -DisplayName $firewallRuleName -Direction Inbound -Action Allow -Protocol TCP -LocalPort $containerLogsPort -EdgeTraversalPolicy Allow

0 commit comments

Comments
 (0)