fill up cpu memory if config is missing

pull/8877/head
Medya Gh 2020-08-03 22:44:38 -07:00
parent e87400db53
commit e783af2bef
1 changed files with 18 additions and 6 deletions

View File

@ -392,9 +392,6 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
cc := *existing 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) { if cmd.Flags().Changed(containerRuntime) {
cc.KubernetesConfig.ContainerRuntime = viper.GetString(containerRuntime) cc.KubernetesConfig.ContainerRuntime = viper.GetString(containerRuntime)
} }
@ -411,19 +408,34 @@ func updateExistingConfigFromFlags(cmd *cobra.Command, existing *config.ClusterC
cc.MinikubeISO = viper.GetString(isoURL) 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) { if cmd.Flags().Changed(memory) {
memInMB, err := pkgutil.CalculateSizeInMB(viper.GetString(memory)) memInMB, err := pkgutil.CalculateSizeInMB(viper.GetString(memory))
if err != nil { if err != nil {
glog.Warningf("error calculate memory size in mb : %v", err) 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.") 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 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.") out.WarningT("You cannot change the CPUs for an existing minikube cluster. Please first delete the cluster.")
} }
} }