Skip to content

Commit

Permalink
Merge pull request #6888 from sharifelgamal/driver
Browse files Browse the repository at this point in the history
Switch --vm-driver paramter to --driver
  • Loading branch information
medyagh authored Mar 5, 2020
2 parents 9c1dbe7 + 34d5f84 commit d5bc3fd
Show file tree
Hide file tree
Showing 39 changed files with 319 additions and 190 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
chmod a+x e2e-*
chmod a+x minikube-*
START_TIME=$(date -u +%s)
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--vm-driver=docker -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
END_TIME=$(date -u +%s)
TIME_ELAPSED=$(($END_TIME-$START_TIME))
min=$((${TIME_ELAPSED}/60))
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
chmod a+x e2e-*
chmod a+x minikube-*
START_TIME=$(date -u +%s)
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--vm-driver=docker -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--driver=docker -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
END_TIME=$(date -u +%s)
TIME_ELAPSED=$(($END_TIME-$START_TIME))
min=$((${TIME_ELAPSED}/60))
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
chmod a+x e2e-*
chmod a+x minikube-*
START_TIME=$(date -u +%s)
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--vm-driver=none -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--driver=none -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
END_TIME=$(date -u +%s)
TIME_ELAPSED=$(($END_TIME-$START_TIME))
min=$((${TIME_ELAPSED}/60))
Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
chmod a+x e2e-*
chmod a+x minikube-*
START_TIME=$(date -u +%s)
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--vm-driver=none -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--driver=none -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
END_TIME=$(date -u +%s)
TIME_ELAPSED=$(($END_TIME-$START_TIME))
min=$((${TIME_ELAPSED}/60))
Expand Down Expand Up @@ -365,7 +365,7 @@ jobs:
chmod a+x e2e-*
chmod a+x minikube-*
START_TIME=$(date -u +%s)
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--vm-driver=podman -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome sudo -E ./e2e-linux-amd64 -minikube-start-args=--driver=podman -test.timeout=70m -test.v -timeout-multiplier=3 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt
END_TIME=$(date -u +%s)
TIME_ELAPSED=$(($END_TIME-$START_TIME))
min=$((${TIME_ELAPSED}/60))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ integration: out/minikube ## Trigger minikube integration test

.PHONY: integration-none-driver
integration-none-driver: e2e-linux-$(GOARCH) out/minikube-linux-$(GOARCH) ## Trigger minikube none driver test
sudo -E out/e2e-linux-$(GOARCH) -testdata-dir "test/integration/testdata" -minikube-start-args="--vm-driver=none" -test.v -test.timeout=60m -binary=out/minikube-linux-amd64 $(TEST_ARGS)
sudo -E out/e2e-linux-$(GOARCH) -testdata-dir "test/integration/testdata" -minikube-start-args="--driver=none" -test.v -test.timeout=60m -binary=out/minikube-linux-amd64 $(TEST_ARGS)

.PHONY: integration-versioned
integration-versioned: out/minikube ## Trigger minikube integration testing
Expand Down
8 changes: 7 additions & 1 deletion cmd/minikube/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type Setting struct {
// These are all the settings that are configurable
// and their validation and callback fn run on Set
var settings = []Setting{
{
name: "driver",
set: SetString,
validations: []setFn{IsValidDriver},
callbacks: []setFn{RequiresRestartMsg},
},
{
name: "vm-driver",
set: SetString,
Expand Down Expand Up @@ -172,7 +178,7 @@ var settings = []Setting{
var ConfigCmd = &cobra.Command{
Use: "config SUBCOMMAND [flags]",
Short: "Modify minikube config",
Long: `config modifies minikube config files using subcommands like "minikube config set vm-driver kvm"
Long: `config modifies minikube config files using subcommands like "minikube config set driver kvm"
Configurable fields: ` + "\n\n" + configurableFields(),
Run: func(cmd *cobra.Command, args []string) {
if err := cmd.Help(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestGetNotFound(t *testing.T) {

func TestGetOK(t *testing.T) {
createTestConfig(t)
name := "vm-driver"
name := "driver"
err := Set(name, "virtualbox")
if err != nil {
t.Fatalf("Set returned error for property %s, %+v", name, err)
Expand Down
12 changes: 6 additions & 6 deletions cmd/minikube/cmd/config/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ func TestNotFound(t *testing.T) {

func TestSetNotAllowed(t *testing.T) {
createTestConfig(t)
err := Set("vm-driver", "123456")
if err == nil || err.Error() != "run validations for \"vm-driver\" with value of \"123456\": [driver \"123456\" is not supported]" {
err := Set("driver", "123456")
if err == nil || err.Error() != "run validations for \"driver\" with value of \"123456\": [driver \"123456\" is not supported]" {
t.Fatalf("Set did not return error for unallowed value: %+v", err)
}
}

func TestSetOK(t *testing.T) {
createTestConfig(t)
err := Set("vm-driver", "virtualbox")
err := Set("driver", "virtualbox")
defer func() {
err = Unset("vm-driver")
err = Unset("driver")
if err != nil {
t.Errorf("failed to unset vm-driver: %+v", err)
t.Errorf("failed to unset driver: %+v", err)
}
}()
if err != nil {
t.Fatalf("Set returned error for valid property value: %+v", err)
}
val, err := Get("vm-driver")
val, err := Get("driver")
if err != nil {
t.Fatalf("Get returned error for valid property: %+v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/minikube/cmd/config/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var minikubeConfig = pkgConfig.MinikubeConfig{
"vm-driver": driver.KVM2,
"driver": driver.KVM2,
"cpus": 12,
"show-libmachine-logs": true,
}
Expand All @@ -38,17 +38,17 @@ func TestFindSettingNotFound(t *testing.T) {
}

func TestFindSetting(t *testing.T) {
s, err := findSetting("vm-driver")
s, err := findSetting("driver")
if err != nil {
t.Fatalf("Couldn't find setting, vm-driver: %v", err)
t.Fatalf("Couldn't find setting, driver: %v", err)
}
if s.name != "vm-driver" {
t.Fatalf("Found wrong setting, expected vm-driver, got %s", s.name)
if s.name != "driver" {
t.Fatalf("Found wrong setting, expected driver, got %s", s.name)
}
}

func TestSetString(t *testing.T) {
err := SetString(minikubeConfig, "vm-driver", driver.VirtualBox)
err := SetString(minikubeConfig, "driver", driver.VirtualBox)
if err != nil {
t.Fatalf("Couldn't set string: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestDriver(t *testing.T) {
},
}

runValidations(t, tests, "vm-driver", IsValidDriver)
runValidations(t, tests, "driver", IsValidDriver)

}

Expand Down
27 changes: 18 additions & 9 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func initMinikubeFlags() {
startCmd.Flags().String(memory, defaultMemorySize, "Amount of RAM allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g).")
startCmd.Flags().String(humanReadableDiskSize, defaultDiskSize, "Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g).")
startCmd.Flags().Bool(downloadOnly, false, "If true, only download and cache files for later use - don't install or start anything.")
startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --vm-driver=none.")
startCmd.Flags().Bool(cacheImages, true, "If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none.")
startCmd.Flags().String(isoURL, constants.DefaultISOURL, "Location of the minikube iso.")
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.")
Expand Down Expand Up @@ -189,7 +189,8 @@ func initKubernetesFlags() {

// initDriverFlags inits the commandline flags for vm drivers
func initDriverFlags() {
startCmd.Flags().String("vm-driver", "", fmt.Sprintf("Driver is one of: %v (defaults to auto-detect)", driver.DisplaySupportedDrivers()))
startCmd.Flags().String("driver", "", fmt.Sprintf("Driver is one of: %v (defaults to auto-detect)", driver.DisplaySupportedDrivers()))
startCmd.Flags().String("vm-driver", "", "DEPRECATED, use `driver` instead.")
startCmd.Flags().Bool(disableDriverMounts, false, "Disables the filesystem mounts provided by the hypervisors")

// kvm2
Expand Down Expand Up @@ -443,15 +444,23 @@ func selectDriver(existing *config.ClusterConfig) registry.DriverState {
return ds
}

if viper.GetString("vm-driver") != "" {
ds := driver.Status(viper.GetString("vm-driver"))
// Default to looking at the new driver parameter
if viper.GetString("driver") != "" {
ds := driver.Status(viper.GetString("driver"))
out.T(out.Sparkle, `Using the {{.driver}} driver based on user configuration`, out.V{"driver": ds.String()})
return ds
}

// Fallback to old driver parameter
if viper.GetString("driver") != "" {
ds := driver.Status(viper.GetString("driver"))
out.T(out.Sparkle, `Using the {{.driver}} driver based on user configuration`, out.V{"driver": ds.String()})
return ds
}

pick, alts := driver.Suggest(driver.Choices())
if pick.Name == "" {
exit.WithCodeT(exit.Config, "Unable to determine a default driver to use. Try specifying --vm-driver, or see https://minikube.sigs.k8s.io/docs/start/")
exit.WithCodeT(exit.Config, "Unable to determine a default driver to use. Try specifying --driver, or see https://minikube.sigs.k8s.io/docs/start/")
}

if len(alts) > 1 {
Expand Down Expand Up @@ -525,7 +534,7 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
* or *
2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} start --vm-driver={{.old_driver}}'
2) Start the existing "{{.profile_name}}" cluster using: '{{.command}} start --driver={{.old_driver}}'
`, out.V{"command": minikubeCmd(), "old_driver": h.Driver.DriverName(), "profile_name": machineName})

exit.WithCodeT(exit.Config, "Exiting.")
Expand Down Expand Up @@ -601,15 +610,15 @@ func validateUser(drvName string) {
useForce := viper.GetBool(force)

if driver.NeedsRoot(drvName) && u.Uid != "0" && !useForce {
exit.WithCodeT(exit.Permissions, `The "{{.driver_name}}" driver requires root privileges. Please run minikube using 'sudo minikube --vm-driver={{.driver_name}}'.`, out.V{"driver_name": drvName})
exit.WithCodeT(exit.Permissions, `The "{{.driver_name}}" driver requires root privileges. Please run minikube using 'sudo minikube --driver={{.driver_name}}'.`, out.V{"driver_name": drvName})
}

if driver.NeedsRoot(drvName) || u.Uid != "0" {
return
}

out.T(out.Stopped, `The "{{.driver_name}}" driver should not be used with root privileges.`, out.V{"driver_name": drvName})
out.T(out.Tip, "If you are running minikube within a VM, consider using --vm-driver=none:")
out.T(out.Tip, "If you are running minikube within a VM, consider using --driver=none:")
out.T(out.Documentation, " https://minikube.sigs.k8s.io/docs/reference/drivers/none/")

if !useForce {
Expand Down Expand Up @@ -851,7 +860,7 @@ func setDockerProxy() {
}
}

// autoSetDriverOptions sets the options needed for specific vm-driver automatically.
// autoSetDriverOptions sets the options needed for specific driver automatically.
func autoSetDriverOptions(cmd *cobra.Command, drvName string) (err error) {
err = nil
hints := driver.FlagDefaults(drvName)
Expand Down
2 changes: 1 addition & 1 deletion hack/conformance_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# conformance_tests.sh <path to minikube> <flags>
#
# Example:
# conformance_tests.sh ./out/minikube --vm-driver=hyperkit
# conformance_tests.sh ./out/minikube --driver=hyperkit
set -ex -o pipefail

readonly PROFILE_NAME="k8sconformance"
Expand Down
4 changes: 2 additions & 2 deletions hack/jenkins/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# The script expects the following env variables:
# OS_ARCH: The operating system and the architecture separated by a hyphen '-' (e.g. darwin-amd64, linux-amd64, windows-amd64)
# VM_DRIVER: the vm-driver to use for the test
# VM_DRIVER: the driver to use for the test
# EXTRA_START_ARGS: additional flags to pass into minikube start
# EXTRA_ARGS: additional flags to pass into minikube
# JOB_NAME: the name of the logfile and check name to update on github
Expand Down Expand Up @@ -285,7 +285,7 @@ if test -f "${TEST_OUT}"; then
fi
touch "${TEST_OUT}"
${SUDO_PREFIX}${E2E_BIN} \
-minikube-start-args="--vm-driver=${VM_DRIVER} ${EXTRA_START_ARGS}" \
-minikube-start-args="--driver=${VM_DRIVER} ${EXTRA_START_ARGS}" \
-expected-default-driver="${EXPECTED_DEFAULT_DRIVER}" \
-test.timeout=70m -test.v \
${EXTRA_TEST_ARGS} \
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 @@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .

./out/minikube-windows-amd64.exe delete

out/e2e-windows-amd64.exe --expected-default-driver=hyperv -minikube-start-args="--vm-driver=hyperv --hyperv-virtual-switch=primary-virtual-switch" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
out/e2e-windows-amd64.exe --expected-default-driver=hyperv -minikube-start-args="--driver=hyperv --hyperv-virtual-switch=primary-virtual-switch" -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=65m
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
Expand Down
2 changes: 1 addition & 1 deletion hack/jenkins/windows_integration_test_virtualbox.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gsutil.cmd -m cp -r gs://minikube-builds/$env:MINIKUBE_LOCATION/testdata .

./out/minikube-windows-amd64.exe delete

out/e2e-windows-amd64.exe -minikube-start-args="--vm-driver=virtualbox" -expected-default-driver=hyperv -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=30m
out/e2e-windows-amd64.exe -minikube-start-args="--driver=virtualbox" -expected-default-driver=hyperv -binary=out/minikube-windows-amd64.exe -test.v -test.timeout=30m
$env:result=$lastexitcode
# If the last exit code was 0->success, x>0->error
If($env:result -eq 0){$env:status="success"}
Expand Down
13 changes: 8 additions & 5 deletions pkg/minikube/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package config

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"reflect"
Expand All @@ -43,13 +44,13 @@ var configTestCases = []configTestCase{
"ReminderWaitPeriodInHours": 99,
"cpus": 4,
"disk-size": "20g",
"driver": "test-driver",
"log_dir": "/etc/hosts",
"show-libmachine-logs": true,
"v": 5,
"vm-driver": "test-driver"
"v": 5
}`,
config: map[string]interface{}{
"vm-driver": "test-driver",
"driver": "test-driver",
"cpus": 4,
"disk-size": "20g",
"v": 5,
Expand Down Expand Up @@ -130,7 +131,7 @@ func TestReadConfig(t *testing.T) {
}

expectedConfig := map[string]interface{}{
"vm-driver": "test-driver",
"driver": "test-driver",
"cpus": 4,
"disk-size": "20g",
"show-libmachine-logs": true,
Expand All @@ -149,7 +150,7 @@ func TestWriteConfig(t *testing.T) {
}

cfg := map[string]interface{}{
"vm-driver": "test-driver",
"driver": "test-driver",
"cpus": 4,
"disk-size": "20g",
"show-libmachine-logs": true,
Expand Down Expand Up @@ -179,6 +180,8 @@ func TestEncode(t *testing.T) {
if err != nil {
t.Errorf("Error encoding: %v", err)
}
fmt.Printf("%+v\n", b.String())
fmt.Printf("%+v\n", tt.data)
if b.String() != tt.data {
t.Errorf("Did not write config correctly, \n\n expected:\n %+v \n\n actual:\n %+v", tt.data, b.String())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"vm-driver": "kvm2",
"driver": "kvm2",
"cpus": 4,
"disk-size": "20g",
"show-libmachine-logs": true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/node/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func trySSH(h *host.Host, ip string) {
- Disable your local VPN or firewall software
- Configure your local VPN or firewall to allow access to {{.ip}}
- Restart or reinstall {{.hypervisor}}
- Use an alternative --vm-driver
- Use an alternative --driver
- Use --force to override this connectivity check
`, out.V{"error": err, "hypervisor": h.Driver.DriverName(), "ip": ip})
}
Expand Down
Loading

0 comments on commit d5bc3fd

Please sign in to comment.