@@ -289,6 +289,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
289
289
exit .Error (reason .RuntimeEnable , "Failed to start container runtime" , err )
290
290
}
291
291
292
+ // Wait for the CRI to actually work, before returning
293
+ err = waitForCRIVersion (runner , cr .SocketPath (), 60 , 10 )
294
+ if err != nil {
295
+ exit .Error (reason .RuntimeEnable , "Failed to start container runtime" , err )
296
+ }
297
+
292
298
return cr
293
299
}
294
300
@@ -332,6 +338,31 @@ func waitForCRISocket(runner cruntime.CommandRunner, socket string, wait int, in
332
338
return nil
333
339
}
334
340
341
+ func waitForCRIVersion (runner cruntime.CommandRunner , socket string , wait int , interval int ) error {
342
+
343
+ if socket == "" || socket == "/var/run/dockershim.sock" {
344
+ return nil
345
+ }
346
+
347
+ klog .Infof ("Will wait %ds for crictl version" , wait )
348
+
349
+ chkInfo := func () error {
350
+ args := []string {"crictl" , "version" }
351
+ cmd := exec .Command ("sudo" , args ... )
352
+ rr , err := runner .RunCmd (cmd )
353
+ if err != nil && ! os .IsNotExist (err ) {
354
+ return & retry.RetriableError {Err : err }
355
+ }
356
+ klog .Info (rr .Stdout .String ())
357
+ return nil
358
+ }
359
+ if err := retry .Expo (chkInfo , time .Duration (interval )* time .Second , time .Duration (wait )* time .Second ); err != nil {
360
+ return err
361
+ }
362
+
363
+ return nil
364
+ }
365
+
335
366
// setupKubeAdm adds any requested files into the VM before Kubernetes is started
336
367
func setupKubeAdm (mAPI libmachine.API , cfg config.ClusterConfig , n config.Node , r command.Runner ) bootstrapper.Bootstrapper {
337
368
bs , err := cluster .Bootstrapper (mAPI , viper .GetString (cmdcfg .Bootstrapper ), cfg , r )
0 commit comments