Skip to content

fix: Don't show VirtualBox warning when auto-selected #21088

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func runStart(cmd *cobra.Command, _ []string) {

useForce := viper.GetBool(force)

starter, err := provisionWithDriver(cmd, ds, existing)
starter, err := provisionWithDriver(cmd, ds, existing, specified)
if err != nil {
node.ExitIfFatal(err, useForce)
machine.MaybeDisplayAdvice(err, ds.Name)
Expand All @@ -252,7 +252,7 @@ func runStart(cmd *cobra.Command, _ []string) {
if err != nil {
out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": ClusterFlagValue()})
}
starter, err = provisionWithDriver(cmd, ds, existing)
starter, err = provisionWithDriver(cmd, ds, existing, false)
if err != nil {
continue
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func runStart(cmd *cobra.Command, _ []string) {
}
}

func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *config.ClusterConfig) (node.Starter, error) {
func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *config.ClusterConfig, driverManuallySpecified bool) (node.Starter, error) {
driverName := ds.Name
klog.Infof("selected driver: %s", driverName)
validateDriver(ds, existing)
Expand Down Expand Up @@ -341,7 +341,7 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
}

rtime := getContainerRuntime(existing)
cc, n, err := generateClusterConfig(cmd, existing, k8sVersion, rtime, driverName)
cc, n, err := generateClusterConfig(cmd, existing, k8sVersion, rtime, driverName, !driverManuallySpecified)
if err != nil {
return node.Starter{}, errors.Wrap(err, "Failed to generate cluster config")
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,20 @@ func ClusterFlagValue() string {
}

// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, rtime string, drvName string) (config.ClusterConfig, config.Node, error) {
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, rtime string, drvName string, driverAutoSelected bool) (config.ClusterConfig, config.Node, error) {
var cc config.ClusterConfig
if existing != nil {
cc = updateExistingConfigFromFlags(cmd, existing)
// Update the DriverAutoSelected flag based on current selection method
cc.DriverAutoSelected = driverAutoSelected

// identify appropriate cni then configure cruntime accordingly
if _, err := cni.New(&cc); err != nil {
return cc, config.Node{}, errors.Wrap(err, "cni")
}
} else {
klog.Info("no existing cluster config was found, will generate one from the flags ")
cc = generateNewConfigFromFlags(cmd, k8sVersion, rtime, drvName)
cc = generateNewConfigFromFlags(cmd, k8sVersion, rtime, drvName, driverAutoSelected)

cnm, err := cni.New(&cc)
if err != nil {
Expand Down Expand Up @@ -547,7 +549,7 @@ func validateVfkitNetwork(n string) string {
}

// generateNewConfigFromFlags generate a config.ClusterConfig based on flags
func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime string, drvName string) config.ClusterConfig {
func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime string, drvName string, driverAutoSelected bool) config.ClusterConfig {
var cc config.ClusterConfig

// networkPlugin cni deprecation warning
Expand Down Expand Up @@ -578,6 +580,7 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
CPUs: getCPUCount(drvName),
DiskSize: getDiskSize(),
Driver: drvName,
DriverAutoSelected: driverAutoSelected,
ListenAddress: viper.GetString(listenAddress),
HyperkitVpnKitSock: viper.GetString(vpnkitSock),
HyperkitVSockPorts: viper.GetStringSlice(vsockPorts),
Expand Down
4 changes: 2 additions & 2 deletions cmd/minikube/cmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func TestMirrorCountry(t *testing.T) {
viper.SetDefault(imageRepository, test.imageRepository)
viper.SetDefault(imageMirrorCountry, test.mirrorCountry)
viper.SetDefault(kvmNUMACount, 1)
config, _, err := generateClusterConfig(cmd, nil, k8sVersion, rtime, driver.Mock)
config, _, err := generateClusterConfig(cmd, nil, k8sVersion, rtime, driver.Mock, false)
if err != nil {
t.Fatalf("Got unexpected error %v during config generation", err)
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestGenerateCfgFromFlagsHTTPProxyHandling(t *testing.T) {

cfg.DockerEnv = []string{} // clear docker env to avoid pollution
proxy.SetDockerEnv()
config, _, err := generateClusterConfig(cmd, nil, k8sVersion, rtime, "none")
config, _, err := generateClusterConfig(cmd, nil, k8sVersion, rtime, "none", false)
if err != nil {
t.Fatalf("Got unexpected error %v during config generation", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type ClusterConfig struct {
CPUs int
DiskSize int
Driver string
DriverAutoSelected bool // Track if driver was auto-selected vs manually chosen
HyperkitVpnKitSock string // Only used by the Hyperkit driver
HyperkitVSockPorts []string // Only used by the Hyperkit driver
DockerEnv []string // Each entry is formatted as KEY=VALUE.
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ func Start(starter Starter) (*kubeconfig.Settings, error) { // nolint:gocyclo
go addons.Enable(&wg, starter.Cfg, list, enabledAddons)
}

// discourage use of the virtualbox driver
if starter.Cfg.Driver == driver.VirtualBox && viper.GetBool(config.WantVirtualBoxDriverWarning) {
// discourage use of the virtualbox driver, but only if it was manually selected
if starter.Cfg.Driver == driver.VirtualBox && !starter.Cfg.DriverAutoSelected && viper.GetBool(config.WantVirtualBoxDriverWarning) {
warnVirtualBox()
}

Expand Down