Skip to content

Commit

Permalink
Merge pull request #10356 from afbjorklund/cri-socket-wait
Browse files Browse the repository at this point in the history
Wait for the CRI socket to be created properly
  • Loading branch information
medyagh authored Feb 6, 2021
2 parents 2c60c12 + 07ea0ec commit bdd1e6d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,55 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
exit.Error(reason.RuntimeEnable, "Failed to enable container runtime", err)
}

// Wait for the CRI to be "live", before returning it
err = waitForCRISocket(runner, cr.SocketPath(), 60, 1)
if err != nil {
exit.Error(reason.RuntimeEnable, "Failed to start container runtime", err)
}

return cr
}

func forceSystemd() bool {
return viper.GetBool("force-systemd") || os.Getenv(constants.MinikubeForceSystemdEnv) == "true"
}

func pathExists(runner cruntime.CommandRunner, path string) (bool, error) {
_, err := runner.RunCmd(exec.Command("stat", path))
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}

func waitForCRISocket(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 socket path %s", wait, socket)

chkPath := func() error {
e, err := pathExists(runner, socket)
if err != nil {
return err
}
if !e {
return &retry.RetriableError{Err: err}
}
return nil
}
if err := retry.Expo(chkPath, 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 bdd1e6d

Please sign in to comment.