@@ -111,6 +111,10 @@ func NewNodes(in *ClusterInput) ([]Node, error) {
111
111
}
112
112
nodes [i ].sshEndpoint = sshEndpoint
113
113
114
+ if err := waitForSSH (nodes [i ]); err != nil {
115
+ return nil , fmt .Errorf ("wait for ssh to be available on node %d: %v" , i , err )
116
+ }
117
+
114
118
privateIP , err := discoverPrivateIP (nodes [i ])
115
119
if err != nil {
116
120
return nil , fmt .Errorf ("discover node private IP: %v" , err )
@@ -206,6 +210,25 @@ func getSSHEndpoint(nodeID string) (string, error) {
206
210
return strings .TrimSpace (string (output )), nil
207
211
}
208
212
213
+ func waitForSSH (node Node ) error {
214
+ timeout := time .After (5 * time .Minute )
215
+ tick := time .Tick (5 * time .Second )
216
+ var lastErr error
217
+
218
+ for {
219
+ select {
220
+ case <- timeout :
221
+ return fmt .Errorf ("timed out after 5 minutes: last error: %w" , lastErr )
222
+ case <- tick :
223
+ _ , _ , err := runCommandOnNode (node , []string {"uptime" })
224
+ if err == nil {
225
+ return nil
226
+ }
227
+ lastErr = err
228
+ }
229
+ }
230
+ }
231
+
209
232
func (c * Cluster ) Airgap () error {
210
233
// Update network policy to airgap
211
234
output , err := exec .Command ("replicated" , "network" , "update" , "policy" , "--id" , c .network .ID , "--policy=airgap" ).CombinedOutput ()
@@ -245,17 +268,15 @@ func (c *Cluster) waitUntilAirgapped(node int) error {
245
268
func (c * Cluster ) WaitForReboot () {
246
269
time .Sleep (30 * time .Second )
247
270
for i := range c .Nodes {
248
- c .refreshSSHEndpoint (i )
271
+ c .waitForSSH (i )
249
272
c .waitForClockSync (i )
250
273
}
251
274
}
252
275
253
- func (c * Cluster ) refreshSSHEndpoint (node int ) {
254
- sshEndpoint , err := getSSHEndpoint (c .Nodes [node ].ID )
255
- if err != nil {
256
- c .t .Fatalf ("failed to refresh ssh endpoint for node %d: %v" , node , err )
276
+ func (c * Cluster ) waitForSSH (node int ) {
277
+ if err := waitForSSH (c .Nodes [node ]); err != nil {
278
+ c .t .Fatalf ("failed to wait for ssh to be available on node %d: %v" , node , err )
257
279
}
258
- c .Nodes [node ].sshEndpoint = sshEndpoint
259
280
}
260
281
261
282
func (c * Cluster ) waitForClockSync (node int ) {
0 commit comments