Skip to content
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
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func runStart(cmd *cobra.Command, _ []string) {

validateBuiltImageVersion(starter.Runner, ds.Name)

if existing != nil && driver.IsKIC(existing.Driver) && viper.GetBool(createMount) {
if existing != nil && driver.IsKIC(existing.Driver) && viper.GetString(mountString) != "" {
old := ""
if len(existing.ContainerVolumeMounts) > 0 {
old = existing.ContainerVolumeMounts[0]
Expand Down
9 changes: 4 additions & 5 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(keepContext, false, "This will keep the existing kubectl context and will create a minikube context.")
startCmd.Flags().Bool(embedCerts, false, "if true, will embed the certs in kubeconfig.")
startCmd.Flags().StringP(containerRuntime, "c", constants.DefaultContainerRuntime, fmt.Sprintf("The container runtime to be used. Valid options: %s (default: auto)", strings.Join(cruntime.ValidRuntimes(), ", ")))
startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube.")
startCmd.Flags().String(mountString, constants.DefaultMountDir+":/minikube-host", "The argument to pass the minikube mount command on start.")
startCmd.Flags().Bool(createMount, false, "Kept for backward compatibility, value is ignored.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can consider hiding this flag (we have a few flags that hidden since we dont want ppl to use them, but left for backward campatiblitiy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding the flag will hide the useful help message. I think we should keep if for now. If we don't use it in the next releases we can hide it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help text, this will be depricated and merged with --mount-string in the next version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #21291, I'll try to get this into 1.37.

startCmd.Flags().String(mountString, "", "Directory to mount in the guest using format '/host-path:/guest-path'.")
startCmd.Flags().String(mount9PVersion, defaultMount9PVersion, mount9PVersionDescription)
startCmd.Flags().String(mountGID, defaultMountGID, mountGIDDescription)
startCmd.Flags().String(mountIPFlag, defaultMountIP, mountIPDescription)
Expand Down Expand Up @@ -614,7 +614,6 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
SSHPort: viper.GetInt(sshSSHPort),
ExtraDisks: viper.GetInt(extraDisks),
CertExpiration: viper.GetDuration(certExpiration),
Mount: viper.GetBool(createMount),
MountString: viper.GetString(mountString),
Mount9PVersion: viper.GetString(mount9PVersion),
MountGID: viper.GetString(mountGID),
Expand Down Expand Up @@ -655,7 +654,8 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
AutoPauseInterval: viper.GetDuration(autoPauseInterval),
}
cc.VerifyComponents = interpretWaitFlag(*cmd)
if viper.GetBool(createMount) && driver.IsKIC(drvName) {

if viper.GetString(mountString) != "" && driver.IsKIC(drvName) {
cc.ContainerVolumeMounts = []string{viper.GetString(mountString)}
}

Expand Down Expand Up @@ -867,7 +867,6 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
updateStringFromFlag(cmd, &cc.KubernetesConfig.ServiceCIDR, serviceCIDR)
updateBoolFromFlag(cmd, &cc.KubernetesConfig.ShouldLoadCachedImages, cacheImages)
updateDurationFromFlag(cmd, &cc.CertExpiration, certExpiration)
updateBoolFromFlag(cmd, &cc.Mount, createMount)
updateStringFromFlag(cmd, &cc.MountString, mountString)
updateStringFromFlag(cmd, &cc.Mount9PVersion, mount9PVersion)
updateStringFromFlag(cmd, &cc.MountGID, mountGID)
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 @@ -88,7 +88,6 @@ type ClusterConfig struct {
MultiNodeRequested bool
ExtraDisks int // currently only implemented for hyperkit and kvm2
CertExpiration time.Duration
Mount bool
MountString string
Mount9PVersion string
MountGID string
Expand Down
22 changes: 0 additions & 22 deletions pkg/minikube/constants/constants_darwin.go

This file was deleted.

26 changes: 0 additions & 26 deletions pkg/minikube/constants/constants_freebsd.go

This file was deleted.

21 changes: 0 additions & 21 deletions pkg/minikube/constants/constants_gendocs.go

This file was deleted.

26 changes: 0 additions & 26 deletions pkg/minikube/constants/constants_linux.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/minikube/constants/constants_windows.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/minikube/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func configureMounts(wg *sync.WaitGroup, cc config.ClusterConfig) {
wg.Add(1)
defer wg.Done()

if !cc.Mount || driver.IsKIC(cc.Driver) {
if cc.MountString == "" || driver.IsKIC(cc.Driver) {
return
}

Expand Down
26 changes: 21 additions & 5 deletions test/integration/mount_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
mountGID = "0"
mountMSize = "6543"
mountUID = "0"
guestPath = "/minikube-host"
)

var mountStartPort = 46463
Expand All @@ -55,14 +56,19 @@ func TestMountStart(t *testing.T) {

// Serial tests
t.Run("serial", func(t *testing.T) {
hostPath := t.TempDir()
startProfileWithMount := func(ctx context.Context, t *testing.T, profile string) {
validateStartWithMount(ctx, t, profile, hostPath)
}

tests := []struct {
name string
validator validateFunc
profile string
}{
{"StartWithMountFirst", validateStartWithMount, profile1},
{"StartWithMountFirst", startProfileWithMount, profile1},
{"VerifyMountFirst", validateMount, profile1},
{"StartWithMountSecond", validateStartWithMount, profile2},
{"StartWithMountSecond", startProfileWithMount, profile2},
{"VerifyMountSecond", validateMount, profile2},
{"DeleteFirst", validateDelete, profile1},
{"VerifyMountPostDelete", validateMount, profile2},
Expand All @@ -87,13 +93,23 @@ func TestMountStart(t *testing.T) {
}

// validateStartWithMount starts a cluster with mount enabled
func validateStartWithMount(ctx context.Context, t *testing.T, profile string) {
func validateStartWithMount(ctx context.Context, t *testing.T, profile string, hostPath string) {
defer PostMortemLogs(t, profile)

// We have to increment this because if you have two mounts with the same port, when you kill one cluster the mount will break for the other
mountStartPort++

args := []string{"start", "-p", profile, "--memory=3072", "--mount", "--mount-gid", mountGID, "--mount-msize", mountMSize, "--mount-port", mountPort(), "--mount-uid", mountUID, "--no-kubernetes"}
args := []string{
"start",
"-p", profile,
"--memory=3072",
"--mount-string", fmt.Sprintf("%s:%s", hostPath, guestPath),
"--mount-gid", mountGID,
"--mount-msize", mountMSize,
"--mount-port", mountPort(),
"--mount-uid", mountUID,
"--no-kubernetes",
}
args = append(args, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
Expand All @@ -110,7 +126,7 @@ func validateMount(ctx context.Context, t *testing.T, profile string) {
sshArgs := []string{"-p", profile, "ssh", "--"}

args := sshArgs
args = append(args, "ls", "/minikube-host")
args = append(args, "ls", guestPath)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
t.Fatalf("mount failed: %q : %v", rr.Command(), err)
Expand Down
Loading