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

mount: Remove --mode flag #13162

Merged
merged 1 commit into from
Dec 14, 2021
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
6 changes: 0 additions & 6 deletions cmd/minikube/cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ const (
mountGIDDescription = "Default group id used for the mount"
defaultMountIP = ""
mountIPDescription = "Specify the ip that the mount should be setup on"
defaultMountMode = 0o755
mountModeDescription = "File permissions used for the mount"
defaultMountMSize = 262144
mountMSizeDescription = "The number of bytes to use for 9p packet payload"
mountOptionsDescription = "Additional mount options, such as cache=fscache"
Expand All @@ -79,7 +77,6 @@ var (
gid string
mSize int
options []string
mode uint
)

// supportedFilesystems is a map of filesystem types to not warn against.
Expand Down Expand Up @@ -166,7 +163,6 @@ var mountCmd = &cobra.Command{
Version: mountVersion,
MSize: mSize,
Port: port,
Mode: os.FileMode(mode),
Options: map[string]string{},
}

Expand Down Expand Up @@ -194,7 +190,6 @@ var mountCmd = &cobra.Command{
out.Infof("Group ID: {{.groupID}}", out.V{"groupID": cfg.GID})
out.Infof("Version: {{.version}}", out.V{"version": cfg.Version})
out.Infof("Message Size: {{.size}}", out.V{"size": cfg.MSize})
out.Infof("Permissions: {{.octalMode}} ({{.writtenMode}})", out.V{"octalMode": fmt.Sprintf("%o", cfg.Mode), "writtenMode": cfg.Mode})
out.Infof("Options: {{.options}}", out.V{"options": cfg.Options})
out.Infof("Bind Address: {{.Address}}", out.V{"Address": net.JoinHostPort(bindIP, fmt.Sprint(port))})

Expand Down Expand Up @@ -245,7 +240,6 @@ func init() {
mountCmd.Flags().BoolVar(&isKill, "kill", false, "Kill the mount process spawned by minikube start")
mountCmd.Flags().StringVar(&uid, constants.MountUIDFlag, defaultMountUID, mountUIDDescription)
mountCmd.Flags().StringVar(&gid, constants.MountGIDFlag, defaultMountGID, mountGIDDescription)
mountCmd.Flags().UintVar(&mode, constants.MountModeFlag, defaultMountMode, mountModeDescription)
mountCmd.Flags().StringSliceVar(&options, constants.MountOptionsFlag, defaultMountOptions(), mountOptionsDescription)
mountCmd.Flags().IntVar(&mSize, constants.MountMSizeFlag, defaultMountMSize, mountMSizeDescription)
}
Expand Down
11 changes: 0 additions & 11 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const (
mount9PVersion = "mount-9p-version"
mountGID = "mount-gid"
mountIPFlag = "mount-ip"
mountMode = "mount-mode"
mountMSize = "mount-msize"
mountOptions = "mount-options"
mountPortFlag = "mount-port"
Expand Down Expand Up @@ -165,7 +164,6 @@ func initMinikubeFlags() {
startCmd.Flags().String(mount9PVersion, defaultMount9PVersion, mount9PVersionDescription)
startCmd.Flags().String(mountGID, defaultMountGID, mountGIDDescription)
startCmd.Flags().String(mountIPFlag, defaultMountIP, mountIPDescription)
startCmd.Flags().Uint(mountMode, defaultMountMode, mountModeDescription)
startCmd.Flags().Int(mountMSize, defaultMountMSize, mountMSizeDescription)
startCmd.Flags().StringSlice(mountOptions, defaultMountOptions(), mountOptionsDescription)
startCmd.Flags().Uint16(mountPortFlag, defaultMountPort, mountPortDescription)
Expand Down Expand Up @@ -487,7 +485,6 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, drvName s
Mount9PVersion: viper.GetString(mount9PVersion),
MountGID: viper.GetString(mountGID),
MountIP: viper.GetString(mountIPFlag),
MountMode: viper.GetUint(mountMode),
MountMSize: viper.GetInt(mountMSize),
MountOptions: viper.GetStringSlice(mountOptions),
MountPort: uint16(viper.GetUint(mountPortFlag)),
Expand Down Expand Up @@ -705,7 +702,6 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
updateStringFromFlag(cmd, &cc.Mount9PVersion, mount9PVersion)
updateStringFromFlag(cmd, &cc.MountGID, mountGID)
updateStringFromFlag(cmd, &cc.MountIP, mountIPFlag)
updateUintFromFlag(cmd, &cc.MountMode, mountMode)
updateIntFromFlag(cmd, &cc.MountMSize, mountMSize)
updateStringSliceFromFlag(cmd, &cc.MountOptions, mountOptions)
updateUint16FromFlag(cmd, &cc.MountPort, mountPortFlag)
Expand Down Expand Up @@ -782,13 +778,6 @@ func updateDurationFromFlag(cmd *cobra.Command, v *time.Duration, key string) {
}
}

// updateUintFromFlag will update the existing uint from the flag.
func updateUintFromFlag(cmd *cobra.Command, v *uint, key string) {
if cmd.Flags().Changed(key) {
*v = viper.GetUint(key)
}
}

// updateUint16FromFlag will update the existing uint16 from the flag.
func updateUint16FromFlag(cmd *cobra.Command, v *uint16, key string) {
if cmd.Flags().Changed(key) {
Expand Down
13 changes: 1 addition & 12 deletions pkg/minikube/cluster/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ package cluster

import (
"fmt"
"os"
"os/exec"
"runtime"
"sort"
"strconv"
"strings"
Expand All @@ -44,8 +42,6 @@ type MountConfig struct {
MSize int
// Port is the port to connect to on the host
Port int
// Mode is the file permissions to set the mount to (octals)
Mode os.FileMode
// Extra mount options. See https://www.kernel.org/doc/Documentation/filesystems/9p.txt
Options map[string]string
}
Expand Down Expand Up @@ -82,7 +78,7 @@ func Mount(r mountRunner, source string, target string, c *MountConfig) error {
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: 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 {
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo mkdir -p %s", target))); err != nil {
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: errors.Wrap(err, "create folder pre-mount")}
}

Expand All @@ -94,13 +90,6 @@ func Mount(r mountRunner, source string, target string, c *MountConfig) error {
return &MountError{ErrorType: MountErrorUnknown, UnderlyingError: errors.Wrapf(err, "mount with cmd %s ", rr.Command())}
}

// skipping macOS due to https://github.com/kubernetes/minikube/issues/13070
if runtime.GOOS != "darwin" {
if _, err := r.RunCmd(exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo chmod %o %s", c.Mode, target))); err != nil {
return &MountError{ErrorType: MountErrorChmod, UnderlyingError: errors.Wrap(err, "chmod folder")}
}
}

klog.Infof("mount successful: %q", rr.Output())
return nil
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/minikube/cluster/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package cluster

import (
"os"
"testing"

"github.com/google/go-cmp/cmp"
Expand All @@ -35,21 +34,21 @@ func TestMntCmd(t *testing.T) {
name: "simple",
source: "src",
target: "target",
cfg: &MountConfig{Type: "9p", Mode: os.FileMode(0700)},
cfg: &MountConfig{Type: "9p"},
want: "sudo mount -t 9p -o dfltgid=0,dfltuid=0,trans=tcp src target",
},
{
name: "named uid",
source: "src",
target: "target",
cfg: &MountConfig{Type: "9p", Mode: os.FileMode(0700), UID: "docker", GID: "docker"},
cfg: &MountConfig{Type: "9p", UID: "docker", GID: "docker"},
want: "sudo mount -t 9p -o dfltgid=$(grep ^docker: /etc/group | cut -d: -f3),dfltuid=$(id -u docker),trans=tcp src target",
},
{
name: "everything",
source: "10.0.0.1",
target: "/target",
cfg: &MountConfig{Type: "9p", Mode: os.FileMode(0777), UID: "82", GID: "72", Version: "9p2000.u", Options: map[string]string{
cfg: &MountConfig{Type: "9p", UID: "82", GID: "72", Version: "9p2000.u", Options: map[string]string{
"noextend": "",
"cache": "fscache",
}},
Expand All @@ -59,7 +58,7 @@ func TestMntCmd(t *testing.T) {
name: "version-conflict",
source: "src",
target: "tgt",
cfg: &MountConfig{Type: "9p", Mode: os.FileMode(0700), Version: "9p2000.u", Options: map[string]string{
cfg: &MountConfig{Type: "9p", Version: "9p2000.u", Options: map[string]string{
"version": "9p2000.L",
}},
want: "sudo mount -t 9p -o dfltgid=0,dfltuid=0,trans=tcp,version=9p2000.L src tgt",
Expand Down
1 change: 0 additions & 1 deletion pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ type ClusterConfig struct {
Mount9PVersion string
MountGID string
MountIP string
MountMode uint
MountMSize int
MountOptions []string
MountPort uint16
Expand Down
2 changes: 0 additions & 2 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ const (
MountIPFlag = "ip"
// MountMSizeFlag is the flag used to set the mount msize
MountMSizeFlag = "msize"
// MountModeFlag is the flag used to set the mount mode
MountModeFlag = "mode"
// MountOptionsFlag is the flag used to set the mount options
MountOptionsFlag = "options"
// MountPortFlag is the flag used to set the mount port
Expand Down
1 change: 0 additions & 1 deletion pkg/minikube/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func generateMountArgs(profile string, cc config.ClusterConfig) []string {
{constants.MountGIDFlag, cc.MountGID},
{constants.MountIPFlag, cc.MountIP},
{constants.MountMSizeFlag, fmt.Sprintf("%d", cc.MountMSize)},
{constants.MountModeFlag, fmt.Sprintf("%d", cc.MountMode)},
{constants.MountPortFlag, fmt.Sprintf("%d", cc.MountPort)},
{constants.MountTypeFlag, cc.MountType},
{constants.MountUIDFlag, cc.MountUID},
Expand Down
1 change: 0 additions & 1 deletion site/content/en/docs/commands/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ minikube mount [flags] <source directory>:<target directory>
--gid string Default group id used for the mount (default "docker")
--ip string Specify the ip that the mount should be setup on
--kill Kill the mount process spawned by minikube start
--mode uint File permissions used for the mount (default 493)
--msize int The number of bytes to use for 9p packet payload (default 262144)
--options strings Additional mount options, such as cache=fscache
--port uint16 Specify the port that the mount should be setup on, where 0 means any free port.
Expand Down
1 change: 0 additions & 1 deletion site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ minikube start [flags]
--mount-9p-version string Specify the 9p version that the mount should use (default "9p2000.L")
--mount-gid string Default group id used for the mount (default "docker")
--mount-ip string Specify the ip that the mount should be setup on
--mount-mode uint File permissions used for the mount (default 493)
--mount-msize int The number of bytes to use for 9p packet payload (default 262144)
--mount-options strings Additional mount options, such as cache=fscache
--mount-port uint16 Specify the port that the mount should be setup on, where 0 means any free port.
Expand Down
25 changes: 2 additions & 23 deletions test/integration/mount_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ import (
"context"
"fmt"
"os/exec"
"runtime"
"strings"
"testing"
)

const (
mountGID = "0"
mountMSize = "6543"
mountMode = "0777"
mountPort = "46464"
mountUID = "0"
)
Expand Down Expand Up @@ -83,7 +81,7 @@ func TestMountStart(t *testing.T) {
func validateStartWithMount(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

args := []string{"start", "-p", profile, "--memory=2048", "--mount", "--mount-gid", mountGID, "--mount-msize", mountMSize, "--mount-mode", mountMode, "--mount-port", mountPort, "--mount-uid", mountUID}
args := []string{"start", "-p", profile, "--memory=2048", "--mount", "--mount-gid", mountGID, "--mount-msize", mountMSize, "--mount-port", mountPort, "--mount-uid", mountUID}
args = append(args, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
Expand All @@ -105,27 +103,8 @@ func validateMount(ctx context.Context, t *testing.T, profile string) {
}

// Docker has it's own mounting method, it doesn't respect the mounting flags
if DockerDriver() {
return
}

// skipping macOS due to https://github.com/kubernetes/minikube/issues/13070
if runtime.GOOS != "darwin" {
args = sshArgs
args = append(args, "stat", "--format", "'%a'", "/minikube-host")
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("failed to get directory mode: %v", err)
}

const want = "777"
if !strings.Contains(rr.Output(), want) {
t.Errorf("wanted mode to be %q; got: %q", want, rr.Output())
}
}

// We can't get the mount details with Hyper-V
if HyperVDriver() {
if DockerDriver() || HyperVDriver() {
return
}

Expand Down
1 change: 0 additions & 1 deletion translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",
"Pausing node {{.name}} ... ": "",
"Permissions: {{.octalMode}} ({{.writtenMode}})": "",
"Please also attach the following file to the GitHub issue:": "",
"Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ": "",
"Please either authenticate to the registry or use --base-image flag to use a different registry.": "",
Expand Down
1 change: 0 additions & 1 deletion translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",
"Pausing node {{.name}} ... ": "",
"Permissions: {{.octalMode}} ({{.writtenMode}})": "",
"Please also attach the following file to the GitHub issue:": "",
"Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ": "",
"Please either authenticate to the registry or use --base-image flag to use a different registry.": "",
Expand Down
2 changes: 2 additions & 0 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"--kvm-numa-count range is 1-8": "la tranche de --kvm-numa-count est 1 à 8",
"--network flag is only valid with the docker/podman and KVM drivers, it will be ignored": "le drapeau --network est valide uniquement avec les pilotes docker/podman et KVM, il va être ignoré",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete {{.profile}}\n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "1) Recréez le cluster avec Kubernetes {{.new}}, en exécutant :\n\t \n\t\t minikube delete {{.profile}}\n\t\t minikube start {{.profile}} - -kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Créez un deuxième cluster avec Kubernetes {{.new}}, en exécutant :\n\t \n \t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Utiliser le cluster existant à la version Kubernetes {{.old}}, en exécutant :\n\t \n\t\t minikube start {{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t \t",
"1) Recreate the cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube delete{{.profile}}\n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t2) Create a second cluster with Kubernetes {{.new}}, by running:\n\t \n\t\t minikube start -p {{.suggestedName}} --kubernetes-version={{.prefix}}{{.new}}\n\t \n\t\t3) Use the existing cluster at version Kubernetes {{.old}}, by running:\n\t \n\t\t minikube start{{.profile}} --kubernetes-version={{.prefix}}{{.old}}\n\t\t": "",
"1. Click on \"Docker for Desktop\" menu icon\n\t\t\t2. Click \"Preferences\"\n\t\t\t3. Click \"Resources\"\n\t\t\t4. Increase \"CPUs\" slider bar to 2 or higher\n\t\t\t5. Click \"Apply \u0026 Restart\"": "1. Cliquez sur l'icône de menu \"Docker for Desktop\"\n\t\t\t2. Cliquez sur \"Preferences\"\n\t\t\t3. Cliquez sur \"Ressources\"\n\t\t\t4. Augmentez la barre de défilement \"CPU\" à 2 ou plus\n\t\t\t5. Cliquez sur \"Apply \u0026 Restart\"",
"1. Click on \"Docker for Desktop\" menu icon\n\t\t\t2. Click \"Preferences\"\n\t\t\t3. Click \"Resources\"\n\t\t\t4. Increase \"Memory\" slider bar to {{.recommend}} or higher\n\t\t\t5. Click \"Apply \u0026 Restart\"": "1. Cliquez sur l'icône de menu \"Docker for Desktop\"\n\t\t\t2. Cliquez sur \"Preferences\"\n\t\t\t3. Cliquez sur \"Ressources\"\n\t\t\t4. Augmentez la barre de défilement \"Memory\" à {{.recommend}} ou plus\n\t\t\t5. Cliquez sur \"Apply \u0026 Restart\"",
"1. Open the \"Docker Desktop\" menu by clicking the Docker icon in the system tray\n\t\t2. Click \"Settings\"\n\t\t3. Click \"Resources\"\n\t\t4. Increase \"CPUs\" slider bar to 2 or higher\n\t\t5. Click \"Apply \u0026 Restart\"": "1. Ouvrez le menu \"Docker Desktop\" en cliquant sur l'icône Docker dans la barre d'état système\n\t\t2. Cliquez sur \"Settings\"\n\t\t3. Cliquez sur \"Ressources\"\n\t\t4. Augmentez la barre de défilement \"CPU\" à 2 ou plus\n\t\t5. Cliquez sur \"Apply \u0026 Restart\"",
Expand Down Expand Up @@ -695,6 +696,7 @@
"Troubleshooting Commands:": "Commandes de dépannage :",
"Try 'minikube delete' to force new SSL certificates to be installed": "Essayez 'minikube delete' pour forcer l'installation de nouveaux certificats SSL",
"Try 'minikube delete', and disable any conflicting VPN or firewall software": "Essayez 'minikube delete' et désactivez tout logiciel VPN ou pare-feu en conflit",
"Try one or more of the following to free up space on the device:\n\t\n\t\t\t1. Run \"docker system prune\" to remove unused Docker data (optionally with \"-a\")\n\t\t\t2. Increase the storage allocated to Docker for Desktop by clicking on:\n\t\t\t\tDocker icon \u003e Preferences \u003e Resources \u003e Disk Image Size\n\t\t\t3. Run \"minikube ssh -- docker system prune\" if using the Docker container runtime": "",
"Try one or more of the following to free up space on the device:\n\t\n\t\t\t1. Run \"docker system prune\" to remove unused Docker data (optionally with \"-a\")\n\t\t\t2. Increase the storage allocated to Docker for Desktop by clicking on:\n\t\t\t\tDocker icon \u003e Settings \u003e Resources \u003e Disk Image Size\n\t\t\t3. Run \"minikube ssh -- docker system prune\" if using the Docker container runtime": "Essayez une ou plusieurs des solutions suivantes pour libérer de l'espace sur l'appareil :\n\t\n\t\t\t1. Exécutez \"docker system prune\" pour supprimer les données Docker inutilisées (éventuellement avec \"-a\")\n\t\t\t2. Augmentez le stockage alloué à Docker for Desktop en cliquant sur :\n\t\t\t\tIcône Docker \u003e Préférences \u003e Ressources \u003e Taille de l'image disque\n\t\t\t3. Exécutez \"minikube ssh -- docker system prune\" si vous utilisez l'environnement d'exécution du conteneur Docker",
"Try one or more of the following to free up space on the device:\n\t\n\t\t\t1. Run \"sudo podman system prune\" to remove unused podman data\n\t\t\t2. Run \"minikube ssh -- docker system prune\" if using the Docker container runtime": "Essayez une ou plusieurs des solutions suivantes pour libérer de l'espace sur l'appareil :\n\t\n\t\t\t1. Exécutez \"sudo podman system prune\" pour supprimer les données podman inutilisées\n\t\t\t2. Exécutez \"minikube ssh -- docker system prune\" si vous utilisez l'environnement d'exécution du conteneur Docker",
"Trying to delete invalid profile {{.profile}}": "Tentative de suppression du profil non valide {{.profile}}",
Expand Down
1 change: 0 additions & 1 deletion translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@
"Paused {{.count}} containers in: {{.namespaces}}": "次のnamespaceに存在する {{.count}} 個のコンテナを停止しました: {{.namespaces}}",
"Pausing node {{.name}} ...": "ノード {{.name}} を一時停止しています ...",
"Pausing node {{.name}} ... ": "",
"Permissions: {{.octalMode}} ({{.writtenMode}})": "",
"Please also attach the following file to the GitHub issue:": "",
"Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ": "",
"Please either authenticate to the registry or use --base-image flag to use a different registry.": "",
Expand Down
1 change: 0 additions & 1 deletion translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@
"Paused {{.count}} containers": "",
"Paused {{.count}} containers in: {{.namespaces}}": "",
"Pausing node {{.name}} ... ": "",
"Permissions: {{.octalMode}} ({{.writtenMode}})": "",
"Please also attach the following file to the GitHub issue:": "",
"Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ": "",
"Please either authenticate to the registry or use --base-image flag to use a different registry.": "",
Expand Down
Loading