docker podman drivers: warn if memory is above limit
parent
380820bb42
commit
b45fd2df8b
|
@ -757,10 +757,38 @@ func memoryLimits(drvName string) (int, int, error) {
|
||||||
return -1, -1, err
|
return -1, -1, err
|
||||||
}
|
}
|
||||||
containerLimit = int(s.TotalMemory / 1024 / 1024)
|
containerLimit = int(s.TotalMemory / 1024 / 1024)
|
||||||
|
myabeAdviceDockerResources(containerLimit, sysLimit, s.CPUs, drvName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sysLimit, containerLimit, nil
|
return sysLimit, containerLimit, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func myabeAdviceDockerResources(containerLimit int, sysLimit int, CPUs int, drvName string) {
|
||||||
|
if drvName == oci.Docker && runtime.GOOS != "linux" {
|
||||||
|
if containerLimit < 2492 {
|
||||||
|
out.T(out.Conflict, `Your Docker Desktop has only {{.container_limit}} memory. Increase memory to at least 2.5 GB or more:
|
||||||
|
|
||||||
|
Docker Icon > Settings > Resources > Memory
|
||||||
|
|
||||||
|
`, out.V{"container_limit": containerLimit})
|
||||||
|
// for users with more than 8 GB advice 3 GB
|
||||||
|
} else if containerLimit < 2997 && sysLimit > 8000 {
|
||||||
|
out.T(out.Tip, `Your system has {{.system_limit}}mb memory but Docker has only {{.container_limit}}mb. For a better performance increase to at least 3 GB.
|
||||||
|
|
||||||
|
Docker Icon > Settings > Resources > Memory
|
||||||
|
|
||||||
|
`, out.V{"container_limit": containerLimit, "system_limit": sysLimit})
|
||||||
|
}
|
||||||
|
if CPUs < 2 {
|
||||||
|
out.T(out.Conflict, `Your Docker Desktop has less than 2 CPUs. Increase CPUs for Docker Desktop:
|
||||||
|
|
||||||
|
Docker icon > Settings > Resources > CPUs
|
||||||
|
|
||||||
|
`, out.V{"container_limit": containerLimit})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// suggestMemoryAllocation calculates the default memory footprint in MB
|
// suggestMemoryAllocation calculates the default memory footprint in MB
|
||||||
func suggestMemoryAllocation(sysLimit int, containerLimit int, nodes int) int {
|
func suggestMemoryAllocation(sysLimit int, containerLimit int, nodes int) int {
|
||||||
if mem := viper.GetInt(memory); mem != 0 {
|
if mem := viper.GetInt(memory); mem != 0 {
|
||||||
|
|
|
@ -232,6 +232,9 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithCodeT(exit.Config, "Generate unable to parse memory '{{.memory}}': {{.error}}", out.V{"memory": viper.GetString(memory), "error": err})
|
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}} service has only {{.container_limit}}mb memory but you specified {{.specified_memory}}mb", out.V{"container_limit": containerLimit, "specified_memory": mem, "driver_name": drvName})
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glog.Infof("Using suggested %dMB memory alloc based on sys=%dMB, container=%dMB", mem, sysLimit, containerLimit)
|
glog.Infof("Using suggested %dMB memory alloc based on sys=%dMB, container=%dMB", mem, sysLimit, containerLimit)
|
||||||
|
|
Loading…
Reference in New Issue