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

Added msize and 9p-version flags to mount. Also changed their defaul… #1705

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions cmd/minikube/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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")
}
4 changes: 2 additions & 2 deletions pkg/minikube/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
}
Expand Down
28 changes: 16 additions & 12 deletions pkg/minikube/cluster/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const (
DefaultUfsPort = "5640"
DefaultUfsDebugLvl = 0
DefaultMountEndpoint = "/minikube-host"
DefaultMsize = 262144
DefaultMountVersion = "9p2000.u"
)

const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"