Skip to content

Commit

Permalink
Fixed mount daemon to be off by default and to use different director…
Browse files Browse the repository at this point in the history
…ies than the current mounts until they are turned off.
  • Loading branch information
aaron-prindle committed May 19, 2017
1 parent d4b5b62 commit 6231443
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 20 deletions.
9 changes: 5 additions & 4 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const (
hypervVirtualSwitch = "hyperv-virtual-switch"
kvmNetwork = "kvm-network"
keepContext = "keep-context"
noMount = "no-mount"
createMount = "mount"
featureGates = "feature-gates"
apiServerName = "apiserver-name"
dnsDomain = "dns-domain"
Expand Down Expand Up @@ -202,9 +202,10 @@ func runStart(cmd *cobra.Command, args []string) {
cmdUtil.MaybeReportErrorAndExit(err)
}

fmt.Printf("Setting up hostmount on %s...\n", viper.GetString(mountString))
// start 9p server mount
if !viper.GetBool(noMount) || cfg.GetMachineName() != constants.DefaultMachineName {
if viper.GetBool(createMount) {
fmt.Printf("Setting up hostmount on %s...\n", viper.GetString(mountString))

path := os.Args[0]
mountDebugVal := 0
if glog.V(8) {
Expand Down Expand Up @@ -259,7 +260,7 @@ func calculateDiskSizeInMB(humanReadableDiskSize string) int {

func init() {
startCmd.Flags().Bool(keepContext, constants.DefaultKeepContext, "This will keep the existing kubectl context and will create a minikube context.")
startCmd.Flags().Bool(noMount, constants.DefaultNoMount, "This will not start the mount daemon and automatically mount files into minikube")
startCmd.Flags().Bool(createMount, false, "This will start the mount daemon and automatically mount files into minikube")
startCmd.Flags().String(mountString, constants.DefaultMountDir+":"+constants.DefaultMountEndpoint, "The argument to pass the minikube mount command on start")
startCmd.Flags().String(isoURL, constants.DefaultIsoUrl, "Location of the minikube iso")
startCmd.Flags().String(vmDriver, constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers))
Expand Down
2 changes: 1 addition & 1 deletion cmd/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func GetPort() (string, error) {
func KillMountProcess() error {
out, err := ioutil.ReadFile(filepath.Join(constants.GetMinipath(), constants.MountProcessFileName))
if err != nil {
return errors.Wrap(err, "error reading mount process from file")
return nil // no mount process to kill
}
pid, err := strconv.Atoi(string(out))
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions hack/jenkins/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sudo rm -rf $HOME/.minikube || true

# Allow this to fail, we'll switch on the return code below.
set +e
out/e2e-${OS_ARCH} -minikube-args="--vm-driver=${VM_DRIVER} --v=10 --no-mount" -test.v -test.timeout=30m -binary=out/minikube-${OS_ARCH}
out/e2e-${OS_ARCH} -minikube-args="--vm-driver=${VM_DRIVER} --v=10" -test.v -test.timeout=30m -binary=out/minikube-${OS_ARCH}
result=$?
set -e

Expand All @@ -55,7 +55,6 @@ MINIKUBE_WANTREPORTERRORPROMPT=False sudo ./out/minikube-${OS_ARCH} delete \
|| true
sudo rm -rf $HOME/.minikube || true


if [[ $result -eq 0 ]]; then
status="success"
else
Expand Down
2 changes: 1 addition & 1 deletion hack/jenkins/windows_integration_test_hyperv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gsutil.cmd cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .
./out/minikube-windows-amd64.exe delete
Remove-Item -Recurse -Force C:\Users\jenkins\.minikube

out/e2e-windows-amd64.exe --% -minikube-args="--vm-driver=hyperv --hyperv-virtual-switch=Minikube --cpus=4 $env:EXTRA_BUILD_ARGS --no-mount" -test.v -test.timeout=30m -binary=out/minikube-windows-amd64.exe
out/e2e-windows-amd64.exe --% -minikube-args="--vm-driver=hyperv --hyperv-virtual-switch=Minikube --v=10 $env:EXTRA_BUILD_ARGS" -test.v -test.timeout=30m -binary=out/minikube-windows-amd64.exe

$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
Expand Down
7 changes: 2 additions & 5 deletions pkg/minikube/cluster/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,11 @@ func GetLogsCommand(follow bool) (string, error) {
var localkubeStatusCommand = `sudo systemctl is-active localkube 2>&1 1>/dev/null && echo "Running" || echo "Stopped"`

func GetMountCleanupCommand(path string) string {
return fmt.Sprintf(`
sudo umount %s;
sudo rm -rf %s;
`, path, path)
return fmt.Sprintf("sudo umount %s;", path)
}

var mountTemplate = `
sudo mkdir -p {{.Path}};
sudo mkdir -p {{.Path}} || true;
sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o uid=1001 -o gid=1001 {{.IP}} {{.Path}};
sudo chmod 775 {{.Path}};`

Expand Down
1 change: 0 additions & 1 deletion pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const (
const (
DefaultUfsPort = "5640"
DefaultUfsDebugLvl = 0
DefaultNoMount = false
)

const IsMinikubeChildProcess = "IS_MINIKUBE_CHILD_PROCESS"
2 changes: 1 addition & 1 deletion pkg/minikube/constants/constants_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ var SupportedVMDrivers = [...]string{
}

var DefaultMountDir = "/Users"
var DefaultMountEndpoint = "/Users"
var DefaultMountEndpoint = "/mount-9p"
2 changes: 1 addition & 1 deletion pkg/minikube/constants/constants_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ var SupportedVMDrivers = [...]string{
}

var DefaultMountDir = homedir.HomeDir()
var DefaultMountEndpoint = "/hosthome"
var DefaultMountEndpoint = "/mount-9p"
2 changes: 1 addition & 1 deletion pkg/minikube/constants/constants_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ var SupportedVMDrivers = [...]string{
}

var DefaultMountDir = homedir.HomeDir()
var DefaultMountEndpoint = "/hostmount"
var DefaultMountEndpoint = "/mount-9p"
6 changes: 3 additions & 3 deletions test/integration/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"testing"
"time"

"github.com/docker/machine/libmachine/state"
"k8s.io/kubernetes/pkg/api"
commonutil "k8s.io/minikube/pkg/util"

"k8s.io/minikube/test/integration/util"
)

Expand Down Expand Up @@ -87,8 +87,8 @@ func TestPersistence(t *testing.T) {
minikubeRunner.RunCommand("stop", true)
minikubeRunner.CheckStatus("Stopped")

minikubeRunner.RunCommand("start", true)
minikubeRunner.CheckStatus("Running")
minikubeRunner.Start()
minikubeRunner.CheckStatus(state.Running.String())

if err := commonutil.RetryAfter(5, checkPod, 3*time.Second); err != nil {
t.Fatalf("Error checking the status of pod %s. Err: %s", podName, err)
Expand Down

0 comments on commit 6231443

Please sign in to comment.