Fix --memory flag parsing in minikube start

Due to the way Go handles variable scope, `mem` was being
redeclared inside the conditional. Outside, we were stuck with the value
provided by `suggestMemoryAllocation`, therefore ignoring the value
passed through the `--memory` flag.
pull/9033/head
Anshul Sirur 2020-08-19 14:43:13 +02:00
parent 348b8c9865
commit 6e8f596eac
1 changed files with 2 additions and 2 deletions

View File

@ -227,14 +227,14 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
mem := suggestMemoryAllocation(sysLimit, containerLimit, viper.GetInt(nodes))
if cmd.Flags().Changed(memory) {
mem, err := pkgutil.CalculateSizeInMB(viper.GetString(memory))
var err error
mem, err = pkgutil.CalculateSizeInMB(viper.GetString(memory))
if err != nil {
exit.WithCodeT(exit.Config, "Generate unable to parse memory '{{.memory}}': {{.error}}", out.V{"memory": viper.GetString(memory), "error": err})
}
if driver.IsKIC(drvName) && mem > containerLimit {
exit.UsageT("{{.driver_name}} has only {{.container_limit}}MB memory but you specified {{.specified_memory}}MB", out.V{"container_limit": containerLimit, "specified_memory": mem, "driver_name": driver.FullName(drvName)})
}
} else {
validateMemorySize(mem, drvName)
glog.Infof("Using suggested %dMB memory alloc based on sys=%dMB, container=%dMB", mem, sysLimit, containerLimit)