Skip to content

Commit

Permalink
Merge pull request #10705 from afbjorklund/cri-version-wait
Browse files Browse the repository at this point in the history
Wait for crictl version after the socket is up
  • Loading branch information
medyagh authored Mar 4, 2021
2 parents 666024b + b0bdf06 commit ba9ca6e
Showing 1 changed file with 31 additions and 0 deletions.
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

0 comments on commit ba9ca6e

Please sign in to comment.