Merge pull request #10356 from afbjorklund/cri-socket-wait
Wait for the CRI socket to be created properlypull/10393/head
commit
bdd1e6de6a
|
|
@ -277,6 +277,12 @@ 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
|
||||
}
|
||||
|
||||
|
|
@ -284,6 +290,42 @@ 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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue