From 66c41fe008b1256688ab31d9ea32cde636d2d1a8 Mon Sep 17 00:00:00 2001 From: Aaron Prindle Date: Mon, 17 Jul 2017 10:00:41 -0700 Subject: [PATCH] Added msize and 9p-version flags to mount. Also changed their defaults to be more usable --- cmd/minikube/cmd/mount.go | 8 ++++++-- pkg/minikube/cluster/cluster.go | 4 ++-- pkg/minikube/cluster/commands.go | 28 ++++++++++++++++------------ pkg/minikube/constants/constants.go | 2 ++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/cmd/minikube/cmd/mount.go b/cmd/minikube/cmd/mount.go index 3054023b8e3b..146d52c3010d 100644 --- a/cmd/minikube/cmd/mount.go +++ b/cmd/minikube/cmd/mount.go @@ -29,14 +29,17 @@ import ( cmdUtil "k8s.io/minikube/cmd/util" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/machine" "k8s.io/minikube/third_party/go9p/ufs" ) var mountIP string +var mountVersion string var isKill bool var uid int var gid int +var msize int // mountCmd represents the mount command var mountCmd = &cobra.Command{ @@ -130,7 +133,7 @@ var mountCmd = &cobra.Command{ ufs.StartServer(net.JoinHostPort(ip.String(), port), debugVal, hostPath) wg.Done() }() - err = cluster.MountHost(api, vmPath, ip, port, uid, gid) + err = cluster.MountHost(api, ip, vmPath, port, mountVersion, uid, gid, msize) if err != nil { fmt.Println(err.Error()) os.Exit(1) @@ -141,8 +144,9 @@ var mountCmd = &cobra.Command{ func init() { mountCmd.Flags().StringVar(&mountIP, "ip", "", "Specify the ip that the mount should be setup on") + mountCmd.Flags().StringVar(&mountVersion, "9p-version", constants.DefaultMountVersion, "Specify the 9p version that the mount should use") mountCmd.Flags().BoolVar(&isKill, "kill", false, "Kill the mount process spawned by minikube start") mountCmd.Flags().IntVar(&uid, "uid", 1001, "Default user id used for the mount") mountCmd.Flags().IntVar(&gid, "gid", 1001, "Default group id used for the mount") - RootCmd.AddCommand(mountCmd) + mountCmd.Flags().IntVar(&msize, "msize", constants.DefaultMsize, "The number of bytes to use for 9p packet payload" } diff --git a/pkg/minikube/cluster/cluster.go b/pkg/minikube/cluster/cluster.go index 1bc5dd4efe3f..85bab4096faf 100644 --- a/pkg/minikube/cluster/cluster.go +++ b/pkg/minikube/cluster/cluster.go @@ -449,7 +449,7 @@ func GetHostLogs(api libmachine.API, follow bool) (string, error) { } // MountHost runs the mount command from the 9p client on the VM to the 9p server on the host -func MountHost(api libmachine.API, path string, ip net.IP, port string, uid, gid int) error { +func MountHost(api libmachine.API, ip net.IP, path, mountVersion, port string, uid, gid, msize int) error { host, err := CheckIfApiExistsAndLoad(api) if err != nil { return errors.Wrap(err, "Error checking that api exists and loading it") @@ -461,7 +461,7 @@ func MountHost(api libmachine.API, path string, ip net.IP, port string, uid, gid } } host.RunSSHCommand(GetMountCleanupCommand(path)) - mountCmd, err := GetMountCommand(ip, path, port, uid, gid) + mountCmd, err := GetMountCommand(ip, path, port, mountVersion, uid, gid, msize) if err != nil { return errors.Wrap(err, "Error getting mount command") } diff --git a/pkg/minikube/cluster/commands.go b/pkg/minikube/cluster/commands.go index 838f9ed1305c..3eb6b4cf534b 100644 --- a/pkg/minikube/cluster/commands.go +++ b/pkg/minikube/cluster/commands.go @@ -233,24 +233,28 @@ func GetMountCleanupCommand(path string) string { var mountTemplate = ` sudo mkdir -p {{.Path}} || true; -sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o dfltuid={{.UID}} -o dfltgid={{.GID}} {{.IP}} {{.Path}}; +sudo mount -t 9p -o trans=tcp,port={{.Port}},dfltuid={{.UID}},dfltgid={{.GID}},version={{.Version}},msize={{.Msize}} {{.IP}} {{.Path}}; sudo chmod 775 {{.Path}};` -func GetMountCommand(ip net.IP, path, port string, uid, gid int) (string, error) { +func GetMountCommand(ip net.IP, path, port, mountVersion string, uid, gid, msize int) (string, error) { t := template.Must(template.New("mountCommand").Parse(mountTemplate)) buf := bytes.Buffer{} data := struct { - IP string - Path string - Port string - UID int - GID int + IP string + Path string + Port string + Version string + UID int + GID int + Msize int }{ - IP: ip.String(), - Path: path, - Port: port, - UID: uid, - GID: gid, + IP: ip.String(), + Path: path, + Port: port, + Version: mountVersion, + UID: uid, + GID: gid, + Msize: msize, } if err := t.Execute(&buf, data); err != nil { return "", err diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index d1d9b0399c13..9c414df299f0 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -133,6 +133,8 @@ const ( DefaultUfsPort = "5640" DefaultUfsDebugLvl = 0 DefaultMountEndpoint = "/minikube-host" + DefaultMsize = 262144 + DefaultMountVersion = "9p2000.u" ) const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"