未验证 提交 bdd1e6de 编写于 作者: M Medya Ghazizadeh 提交者: GitHub

Merge pull request #10356 from afbjorklund/cri-socket-wait

Wait for the CRI socket to be created properly
...@@ -277,6 +277,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k ...@@ -277,6 +277,12 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
exit.Error(reason.RuntimeEnable, "Failed to enable container runtime", err) 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 return cr
} }
...@@ -284,6 +290,42 @@ func forceSystemd() bool { ...@@ -284,6 +290,42 @@ func forceSystemd() bool {
return viper.GetBool("force-systemd") || os.Getenv(constants.MinikubeForceSystemdEnv) == "true" 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 // 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 { 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) bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册