Skip to content

Wait for crictl version after the socket is up #10705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
exit.Error(reason.RuntimeEnable, "Failed to start container runtime", err)
}

// Wait for the CRI to actually work, before returning
err = waitForCRIVersion(runner, cr.SocketPath(), 60, 10)
if err != nil {
exit.Error(reason.RuntimeEnable, "Failed to start container runtime", err)
}

return cr
}

Expand Down Expand Up @@ -332,6 +338,31 @@ func waitForCRISocket(runner cruntime.CommandRunner, socket string, wait int, in
return nil
}

func waitForCRIVersion(runner cruntime.CommandRunner, socket string, wait int, interval int) error {

if socket == "" || socket == "/var/run/dockershim.sock" {
return nil
}

klog.Infof("Will wait %ds for crictl version", wait)

chkInfo := func() error {
args := []string{"crictl", "version"}
cmd := exec.Command("sudo", args...)
rr, err := runner.RunCmd(cmd)
if err != nil && !os.IsNotExist(err) {
return &retry.RetriableError{Err: err}
}
klog.Info(rr.Stdout.String())
return nil
}
if err := retry.Expo(chkInfo, time.Duration(interval)*time.Second, time.Duration(wait)*time.Second); err != nil {
return err
}

return nil
}

// setupKubeAdm adds any requested files into the VM before Kubernetes is started
func setupKubeAdm(mAPI libmachine.API, cfg config.ClusterConfig, n config.Node, r command.Runner) bootstrapper.Bootstrapper {
bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)
Expand Down