Skip to content

Commit db2e16c

Browse files
Merge pull request #3139 from openshift-cherrypick-robot/cherry-pick-3135-to-release-4.19
[release-4.19] OCPBUGS-56131: Retry SSH server initialization
2 parents a282150 + 0946260 commit db2e16c

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)