Skip to content

Commit b0bdf06

Browse files
committed
Wait for crictl version after the socket is up
As there are no guarantees that the CRI socket actually _works_, just because it has been made available by the container runtime.
1 parent d9c02d1 commit b0bdf06

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pkg/minikube/node/start.go

+31
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
289289
exit.Error(reason.RuntimeEnable, "Failed to start container runtime", err)
290290
}
291291

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+
292298
return cr
293299
}
294300

@@ -332,6 +338,31 @@ func waitForCRISocket(runner cruntime.CommandRunner, socket string, wait int, in
332338
return nil
333339
}
334340

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+
335366
// setupKubeAdm adds any requested files into the VM before Kubernetes is started
336367
func setupKubeAdm(mAPI libmachine.API, cfg config.ClusterConfig, n config.Node, r command.Runner) bootstrapper.Bootstrapper {
337368
bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)

0 commit comments

Comments
 (0)