Create advice for mount command timing out.

pull/11979/head
Andriy Dzikh 2021-07-14 15:38:04 -07:00
parent 354fedb073
commit 49cd3840d3
3 changed files with 20 additions and 9 deletions
cmd/minikube/cmd
pkg/minikube
cluster
reason

View File

@ -190,10 +190,7 @@ var mountCmd = &cobra.Command{
}
}()
err = cluster.Mount(co.CP.Runner, ip.String(), vmPath, cfg)
if err != nil {
exit.Error(reason.GuestMount, "mount failed", err)
}
cluster.Mount(co.CP.Runner, ip.String(), vmPath, cfg)
out.Step(style.Success, "Successfully mounted {{.sourcePath}} to {{.destinationPath}}", out.V{"sourcePath": hostPath, "destinationPath": vmPath})
out.Ln("")
out.Styled(style.Notice, "NOTE: This process must stay alive for the mount to be accessible ...")

View File

@ -27,6 +27,8 @@ import (
"github.com/pkg/errors"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/reason"
)
// MountConfig defines the options available to the Mount command
@ -55,22 +57,25 @@ type mountRunner interface {
}
// Mount runs the mount command from the 9p client on the VM to the 9p server on the host
func Mount(r mountRunner, source string, target string, c *MountConfig) error {
func Mount(r mountRunner, source string, target string, c *MountConfig) {
if err := Unmount(r, target); err != nil {
return errors.Wrap(err, "umount")
exit.Error(reason.GuestMount, "mount failed", errors.Wrap(err, "umount"))
}
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -m %o -p %s", c.Mode, target))); err != nil {
return errors.Wrap(err, "create folder pre-mount")
exit.Error(reason.GuestMount, "mount failed", errors.Wrap(err, "create folder pre-mount"))
}
rr, err := r.RunCmd(exec.Command("/bin/bash", "-c", mntCmd(source, target, c)))
if err != nil {
return errors.Wrapf(err, "mount with cmd %s ", rr.Command())
if strings.Contains(rr.Stderr.String(), "Connection timed out") {
exit.Error(reason.GuestMountCouldNotConnect, "mount could not connect", err)
} else {
exit.Error(reason.GuestMount, "mount failed", errors.Wrapf(err, "mount with cmd %s ", rr.Command()))
}
}
klog.Infof("mount successful: %q", rr.Output())
return nil
}
// returns either a raw UID number, or the subshell to resolve it.

View File

@ -321,6 +321,15 @@ var (
GuestLoadHost = Kind{ID: "GUEST_LOAD_HOST", ExitCode: ExGuestError}
// minkube failed to create a mount
GuestMount = Kind{ID: "GUEST_MOUNT", ExitCode: ExGuestError}
// mount on guest was unable to connect to host mount server
GuestMountCouldNotConnect = Kind{
ID: "GUEST_MOUNT_COULD_NOT_CONNECT",
ExitCode: ExGuestError,
Advice: `If the host has a firewall:
1. Allow a port through the firewall
2. Specify "--port=<port_number>" for "minikube mount"`,
}
// minkube failed to update a mount
GuestMountConflict = Kind{ID: "GUEST_MOUNT_CONFLICT", ExitCode: ExGuestConflict}
// minikube failed to add a node to the cluster