diff --git a/cmd/minikube/cmd/start_flags.go b/cmd/minikube/cmd/start_flags.go index bb06d392c1..3ecbfff8c8 100644 --- a/cmd/minikube/cmd/start_flags.go +++ b/cmd/minikube/cmd/start_flags.go @@ -392,9 +392,6 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC cc := *existing - // validate the memory size in case user changed their system memory limits (example change docker desktop or upgraded memory.) - validateMemorySize(cc.Memory, cc.Driver) - if cmd.Flags().Changed(containerRuntime) { cc.KubernetesConfig.ContainerRuntime = viper.GetString(containerRuntime) } @@ -411,19 +408,34 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC cc.MinikubeISO = viper.GetString(isoURL) } + if cc.Memory == 0 { + glog.Info("Existing config file was missing memory. (could be an old minikube config), will use the default value") + memInMB, err := pkgutil.CalculateSizeInMB(viper.GetString(memory)) + if err != nil { + glog.Warningf("error calculate memory size in mb : %v", err) + } + cc.Memory = memInMB + } + if cmd.Flags().Changed(memory) { memInMB, err := pkgutil.CalculateSizeInMB(viper.GetString(memory)) if err != nil { glog.Warningf("error calculate memory size in mb : %v", err) } - if memInMB != existing.Memory { + if memInMB != cc.Memory { out.WarningT("You cannot change the memory size for an exiting minikube cluster. Please first delete the cluster.") } - } + // validate the memory size in case user changed their system memory limits (example change docker desktop or upgraded memory.) + validateMemorySize(cc.Memory, cc.Driver) + + if cc.CPUs == 0 { + glog.Info("Existing config file was missing cpu. (could be an old minikube config), will use the default value") + cc.CPUs = viper.GetInt(cpus) + } if cmd.Flags().Changed(cpus) { - if viper.GetInt(cpus) != existing.CPUs { + if viper.GetInt(cpus) != cc.CPUs { out.WarningT("You cannot change the CPUs for an existing minikube cluster. Please first delete the cluster.") } }