Skip to content

Commit

Permalink
Wait for crictl version after the socket is up
Browse files Browse the repository at this point in the history
As there are no guarantees that the CRI socket actually _works_,
just because it has been made available by the container runtime.
  • Loading branch information
afbjorklund committed Mar 3, 2021
1 parent d9c02d1 commit bb57779
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 info", 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 bb57779

Please sign in to comment.