Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: add solution message for noexec mount volumes #8597

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/minikube/cmd/node_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var nodeStartCmd = &cobra.Command{
if err != nil {
_, err := maybeDeleteAndRetry(*cc, *n, nil, err)
sharifelgamal marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
maybeExitWithAdvice(err)
exit.WithError("failed to start node", err)
}
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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("")
Expand All @@ -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`)
}

}
32 changes: 32 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
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")}
15 changes: 11 additions & 4 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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
Expand Down