提交 08df5e2d 编写于 作者: M Medya Gh

add solution message if kbueadm is not executble on linux

上级 4485c5c3
......@@ -70,6 +70,7 @@ var nodeStartCmd = &cobra.Command{
if err != nil {
_, err := maybeDeleteAndRetry(*cc, *n, nil, err)
if err != nil {
maybeExitWithAdvice(err)
exit.WithError("failed to start node", err)
}
}
......
......@@ -44,6 +44,7 @@ import (
"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/bootstrapper/bsutil"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/download"
......@@ -1045,7 +1046,7 @@ func getKubernetesVersion(old *config.ClusterConfig) string {
return nv
}
// maybeExitWithAdvice before exiting will try to check for different error types and provide advice
// maybeExitWithAdvice before exiting will try to check for different error types and provide advice if we know for sure what the error is
func maybeExitWithAdvice(err error) {
if errors.Is(err, oci.ErrWindowsContainers) {
out.ErrLn("")
......@@ -1071,8 +1072,15 @@ func maybeExitWithAdvice(err error) {
out.T(out.Tip, "Please ensure your {{.driver_name}} system has access to {{.cpu_counts}} CPU cores or reduce the number of the specified CPUs", out.V{"driver_name": viper.GetString("driver"), "cpu_counts": viper.GetInt(cpus)})
}
}
exit.UsageT("Ensure your {{.driver_name}} system has enough CPUs. The minimum allowed is 2 CPUs.", out.V{"driver_name": viper.GetString("driver")})
}
if errors.Is(err, kubeadm.ErrNoExecLinux) {
out.ErrLn("")
out.ErrT(out.Conflict, "kubeadm binary is not executable !")
out.T(out.Documentation, "Other users fixed this as explained in this issue: https://github.com/kubernetes/minikube/issues/8327#issuecomment-651288459")
exit.UsageT(`Ensure the binaries are not mounted with "noexec" option. To see list of your mount permissions run:
findmnt`)
}
}
/*
Copyright 2020 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kubeadm
import "errors"
// FailFastError type is an error that could not be solved by trying again
type FailFastError struct {
Err error
}
func (f *FailFastError) Error() string {
return f.Err.Error()
}
// ErrNoExecLinux is thrown on linux when the kubeadm binaries are mounted in a noexec volume on Linux as seen in https://github.com/kubernetes/minikube/issues/8327#issuecomment-651288459
// this error could be seen on docker/podman or none driver.
var ErrNoExecLinux = &FailFastError{errors.New("mounted kubeadm binary is not executable")}
......@@ -227,6 +227,9 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig) error {
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("%s init --config %s %s --ignore-preflight-errors=%s",
bsutil.InvokeKubeadm(cfg.KubernetesConfig.KubernetesVersion), conf, extraFlags, strings.Join(ignore, ",")))
if _, err := k.c.RunCmd(c); err != nil {
if strings.Contains(err.Error(), "'kubeadm': Permission denied") {
return ErrNoExecLinux
}
return errors.Wrap(err, "run")
}
......@@ -348,11 +351,15 @@ func (k *Bootstrapper) StartCluster(cfg config.ClusterConfig) error {
return nil
}
out.ErrT(out.Conflict, "initialization failed, will try again: {{.error}}", out.V{"error": err})
if err := k.DeleteCluster(cfg.KubernetesConfig); err != nil {
glog.Warningf("delete failed: %v", err)
// retry again if it is not a fail fast error
if _, ff := err.(*FailFastError); !ff {
out.ErrT(out.Conflict, "initialization failed, will try again: {{.error}}", out.V{"error": err})
if err := k.DeleteCluster(cfg.KubernetesConfig); err != nil {
glog.Warningf("delete failed: %v", err)
}
return k.init(cfg)
}
return k.init(cfg)
return err
}
// client sets and returns a Kubernetes client to use to speak to a kubeadm launched apiserver
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册