From 0e665930e86e118976b5c6b3912aaed51ccfe20f Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Wed, 14 Jul 2021 15:00:22 +0530 Subject: [PATCH 1/8] Add message to discourage the use of virtualbox driver --- cmd/minikube/cmd/config/config.go | 4 ++++ cmd/minikube/cmd/root.go | 1 + pkg/minikube/config/config.go | 2 ++ pkg/minikube/node/start.go | 17 +++++++++++++++++ site/content/en/docs/commands/config.md | 1 + 5 files changed, 25 insertions(+) diff --git a/cmd/minikube/cmd/config/config.go b/cmd/minikube/cmd/config/config.go index 509d202eba..738ac8badc 100644 --- a/cmd/minikube/cmd/config/config.go +++ b/cmd/minikube/cmd/config/config.go @@ -126,6 +126,10 @@ var settings = []Setting{ name: config.WantNoneDriverWarning, set: SetBool, }, + { + name: config.WantVirtualBoxDriverWarning, + set: SetBool, + }, { name: config.ProfileName, set: SetString, diff --git a/cmd/minikube/cmd/root.go b/cmd/minikube/cmd/root.go index 9049596c09..785a2db36b 100644 --- a/cmd/minikube/cmd/root.go +++ b/cmd/minikube/cmd/root.go @@ -305,6 +305,7 @@ func setupViper() { viper.SetDefault(config.WantUpdateNotification, true) viper.SetDefault(config.ReminderWaitPeriodInHours, 24) viper.SetDefault(config.WantNoneDriverWarning, true) + viper.SetDefault(config.WantVirtualBoxDriverWarning, true) } func addToPath(dir string) { diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index 893844eaee..a1129fcb72 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -38,6 +38,8 @@ const ( ReminderWaitPeriodInHours = "ReminderWaitPeriodInHours" // WantNoneDriverWarning is the key for WantNoneDriverWarning WantNoneDriverWarning = "WantNoneDriverWarning" + // WantVirtualBoxDriverWarning is the key for WantVirtualBoxDriverWarning + WantVirtualBoxDriverWarning = "WantVirtualBoxDriverWarning" // ProfileName represents the key for the global profile parameter ProfileName = "profile" // UserFlag is the key for the global user flag (ex. --user=user1) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index c8a79d0889..33ee50c99b 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -191,6 +191,23 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { go addons.Start(&wg, starter.Cfg, starter.ExistingAddons, addonList) } + // discourage use of the virtualbox driver + if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) { + var altDriverList strings.Builder + for _, d := range driver.Choices(true) { + if d.Name != "virtualbox" { + altDriverList.WriteString(fmt.Sprintf("\t- %s\n", d.Name)) + } + } + + out.ErrT(style.Empty, "") + out.WarningT("The 'virtualbox' driver could be troublesome to work with, do not use if you aren't familiar with it") + out.ErrT(style.Tip, "You could instead use one of the drivers listed below:") + out.ErrT(style.Empty, altDriverList.String()) + out.ErrT(style.Documentation, "For more information, see: https://minikube.sigs.k8s.io/docs/reference/drivers/virtualbox/") + out.ErrT(style.Empty, "") + } + if apiServer { // special ops for none , like change minikube directory. // multinode super doesn't work on the none driver diff --git a/site/content/en/docs/commands/config.md b/site/content/en/docs/commands/config.md index b6b4016965..75f99b44e3 100644 --- a/site/content/en/docs/commands/config.md +++ b/site/content/en/docs/commands/config.md @@ -30,6 +30,7 @@ Configurable fields: * WantBetaUpdateNotification * ReminderWaitPeriodInHours * WantNoneDriverWarning + * WantVirtualBoxDriverWarning * profile * bootstrapper * insecure-registry From b3696ea3b81becbb3fded926ac4d283e089cc023 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 16 Jul 2021 02:13:14 +0530 Subject: [PATCH 2/8] Refactor message into a box dialog --- pkg/minikube/node/start.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 33ee50c99b..31a18ebf5a 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -194,18 +194,13 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { // discourage use of the virtualbox driver if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) { var altDriverList strings.Builder - for _, d := range driver.Choices(true) { - if d.Name != "virtualbox" { - altDriverList.WriteString(fmt.Sprintf("\t- %s\n", d.Name)) + for _, choice := range driver.Choices(true) { + if choice.Name != "virtualbox" { + altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) } } - out.ErrT(style.Empty, "") - out.WarningT("The 'virtualbox' driver could be troublesome to work with, do not use if you aren't familiar with it") - out.ErrT(style.Tip, "You could instead use one of the drivers listed below:") - out.ErrT(style.Empty, altDriverList.String()) - out.ErrT(style.Documentation, "For more information, see: https://minikube.sigs.k8s.io/docs/reference/drivers/virtualbox/") - out.ErrT(style.Empty, "") + out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) } if apiServer { From dfb624117c5aecc52f519cad6b5f7364d68c6dbd Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Fri, 16 Jul 2021 18:46:07 +0530 Subject: [PATCH 3/8] Improve cyclomatic complexity, move warning into separate function --- pkg/minikube/node/start.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 31a18ebf5a..d67aacbc78 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -193,14 +193,7 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { // discourage use of the virtualbox driver if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) { - var altDriverList strings.Builder - for _, choice := range driver.Choices(true) { - if choice.Name != "virtualbox" { - altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) - } - } - - out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) + warnVirtualBox() } if apiServer { @@ -743,3 +736,15 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo return nil } + +// prints a warning to the console against the use of the 'virtualbox' driver +func warnVirtualBox() { + var altDriverList strings.Builder + for _, choice := range driver.Choices(true) { + if choice.Name != "virtualbox" { + altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) + } + } + + out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) +} From 3fb51c4cfcd757c7361b3eafbc95537719d76953 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Sat, 17 Jul 2021 15:34:59 +0530 Subject: [PATCH 4/8] Ensure message is shown only if alternatives are available --- pkg/minikube/node/start.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index d67aacbc78..28442ae12c 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -746,5 +746,7 @@ func warnVirtualBox() { } } - out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) + if altDriverList.Len() != 0 { + out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) + } } From 86dba80fb31ce43c77cfddc0b78e1c8a73c05504 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Sat, 17 Jul 2021 15:43:14 +0530 Subject: [PATCH 5/8] Ensure available alternatives aren't either discouraged or not installed --- pkg/minikube/node/start.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 28442ae12c..942d0a636e 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -61,6 +61,7 @@ import ( "k8s.io/minikube/pkg/minikube/out/register" "k8s.io/minikube/pkg/minikube/proxy" "k8s.io/minikube/pkg/minikube/reason" + "k8s.io/minikube/pkg/minikube/registry" "k8s.io/minikube/pkg/minikube/style" "k8s.io/minikube/pkg/minikube/vmpath" "k8s.io/minikube/pkg/util" @@ -737,11 +738,11 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo return nil } -// prints a warning to the console against the use of the 'virtualbox' driver +// prints a warning to the console against the use of the 'virtualbox' driver, if alternatives are available func warnVirtualBox() { var altDriverList strings.Builder for _, choice := range driver.Choices(true) { - if choice.Name != "virtualbox" { + if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && !(choice.Name == "vmware" && !choice.State.Installed) { altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) } } From e30f9e2e626e5814cbb2c33728695223c2a2f680 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Sat, 17 Jul 2021 15:57:59 +0530 Subject: [PATCH 6/8] Ensure if alternative vmware is healthy before recommeding --- pkg/minikube/node/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 942d0a636e..24a01d9fc3 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -742,7 +742,7 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo func warnVirtualBox() { var altDriverList strings.Builder for _, choice := range driver.Choices(true) { - if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && !(choice.Name == "vmware" && !choice.State.Installed) { + if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && !(choice.Name == "vmware" && !(choice.State.Installed && choice.State.Healthy)) { altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) } } From 892b3140205568e2fbf5d7adbdc63450e94648e3 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Tue, 20 Jul 2021 09:06:25 +0530 Subject: [PATCH 7/8] Rewrite suggestion and change if statement --- pkg/minikube/node/start.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 24a01d9fc3..4026ed5b5d 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -738,16 +738,16 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo return nil } -// prints a warning to the console against the use of the 'virtualbox' driver, if alternatives are available +// prints a warning to the console against the use of the 'virtualbox' driver, if alternatives are available and healthy func warnVirtualBox() { var altDriverList strings.Builder for _, choice := range driver.Choices(true) { - if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && !(choice.Name == "vmware" && !(choice.State.Installed && choice.State.Healthy)) { + if choice.Name != "virtualbox" && choice.Priority != registry.Discouraged && choice.State.Installed && choice.State.Healthy { altDriverList.WriteString(fmt.Sprintf("\n\t- %s", choice.Name)) } } if altDriverList.Len() != 0 { - out.Boxed("There are alternative drivers to virtualbox for better performance and support, consider using them {{.drivers}} \nTo turn this warning off use `minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) + out.Boxed("You have selected Virtualbox driver, but there are better options, for better performance and support consider using a different driver: {{.drivers}} \nTo turn off this suggestion run \n`minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) } } From a6bfbd1580807735ac1d954934a130135f769cf8 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 26 Jul 2021 16:40:43 -0700 Subject: [PATCH 8/8] update the warnning --- pkg/minikube/node/start.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 4026ed5b5d..6e1e435714 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -748,6 +748,17 @@ func warnVirtualBox() { } if altDriverList.Len() != 0 { - out.Boxed("You have selected Virtualbox driver, but there are better options, for better performance and support consider using a different driver: {{.drivers}} \nTo turn off this suggestion run \n`minikube config set WantVirtualBoxDriverWarning false`", out.V{"drivers": altDriverList.String()}) + out.Boxed(`You have selected "virtualbox" driver, but there are better options ! +For better performance and support consider using a different driver: {{.drivers}} + +To turn off this warning run: + + $ minikube config set WantVirtualBoxDriverWarning false + + +To learn more about on minikube drivers checkout https://minikube.sigs.k8s.io/docs/drivers/ +To see benchmarks checkout https://minikube.sigs.k8s.io/docs/benchmarks/cpuusage/ + +`, out.V{"drivers": altDriverList.String()}) } }