Merge pull request #8959 from medyagh/valid_mem_docker
improve error handling for validating memory limitspull/8975/head
commit
5ed6c988ec
|
@ -497,7 +497,7 @@ jobs:
|
|||
$env:KUBECONFIG="${pwd}\testhome\kubeconfig"
|
||||
$env:MINIKUBE_HOME="${pwd}\testhome"
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
.\e2e-windows-amd64.exe --minikube-start-args="--driver=hyperv" --test.timeout=15m --timeout-multiplier=1.5 --test.v --test.run=TestFunctional --binary=./minikube-windows-amd64.exe | Tee-Object -FilePath ".\report\testout.txt"
|
||||
.\e2e-windows-amd64.exe --minikube-start-args="--driver=hyperv" --test.timeout=20m --timeout-multiplier=1.5 --test.v --test.run=TestFunctional --binary=./minikube-windows-amd64.exe | Tee-Object -FilePath ".\report\testout.txt"
|
||||
$END_TIME=(GET-DATE)
|
||||
echo $END_TIME
|
||||
$DURATION=(NEW-TIMESPAN -Start $START_TIME -End $END_TIME)
|
||||
|
|
|
@ -495,7 +495,7 @@ jobs:
|
|||
$env:KUBECONFIG="${pwd}\testhome\kubeconfig"
|
||||
$env:MINIKUBE_HOME="${pwd}\testhome"
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
.\e2e-windows-amd64.exe --minikube-start-args="--driver=hyperv" --test.timeout=15m --timeout-multiplier=1.5 --test.v --test.run=TestFunctional --binary=./minikube-windows-amd64.exe | Tee-Object -FilePath ".\report\testout.txt"
|
||||
.\e2e-windows-amd64.exe --minikube-start-args="--driver=hyperv" --test.timeout=20m --timeout-multiplier=1.5 --test.v --test.run=TestFunctional --binary=./minikube-windows-amd64.exe | Tee-Object -FilePath ".\report\testout.txt"
|
||||
$END_TIME=(GET-DATE)
|
||||
echo $END_TIME
|
||||
$DURATION=(NEW-TIMESPAN -Start $START_TIME -End $END_TIME)
|
||||
|
|
|
@ -765,10 +765,18 @@ func validateUser(drvName string) {
|
|||
|
||||
// memoryLimits returns the amount of memory allocated to the system and hypervisor , the return value is in MB
|
||||
func memoryLimits(drvName string) (int, int, error) {
|
||||
info, err := machine.CachedHostInfo()
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
info, cpuErr, memErr, diskErr := machine.CachedHostInfo()
|
||||
if cpuErr != nil {
|
||||
glog.Warningf("could not get system cpu info while verifying memory limits, which might be okay: %v", cpuErr)
|
||||
}
|
||||
if diskErr != nil {
|
||||
glog.Warningf("could not get system disk info while verifying memory limits, which might be okay: %v", diskErr)
|
||||
}
|
||||
|
||||
if memErr != nil {
|
||||
return -1, -1, memErr
|
||||
}
|
||||
|
||||
sysLimit := int(info.Memory)
|
||||
containerLimit := 0
|
||||
|
||||
|
@ -827,9 +835,11 @@ func validateMemoryHardLimit(drvName string) {
|
|||
if err != nil {
|
||||
glog.Warningf("Unable to query memory limits: %v", err)
|
||||
out.WarningT("Failed to verify system memory limits.")
|
||||
return
|
||||
}
|
||||
if s < 2200 {
|
||||
out.WarningT("Your system has only {{.memory_amount}}MB memory. This might not work minimum required is 2000MB.", out.V{"memory_amount": s})
|
||||
return
|
||||
}
|
||||
if driver.IsDockerDesktop(drvName) {
|
||||
// in Docker Desktop if you allocate 2 GB the docker info shows: Total Memory: 1.945GiB which becomes 1991 when we calculate the MBs
|
||||
|
|
|
@ -222,12 +222,12 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
|
|||
glog.Info("no existing cluster config was found, will generate one from the flags ")
|
||||
sysLimit, containerLimit, err := memoryLimits(drvName)
|
||||
if err != nil {
|
||||
glog.Warningf("Unable to query memory limits: %v", err)
|
||||
glog.Warningf("Unable to query memory limits: %+v", err)
|
||||
}
|
||||
|
||||
mem := suggestMemoryAllocation(sysLimit, containerLimit, viper.GetInt(nodes))
|
||||
if cmd.Flags().Changed(memory) {
|
||||
mem, err = pkgutil.CalculateSizeInMB(viper.GetString(memory))
|
||||
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})
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ func CachedDaemonInfo(ociBin string) (SysInfo, error) {
|
|||
cachedSysInfo = &si
|
||||
cachedSysInfoErr = &err
|
||||
}
|
||||
if cachedSysInfoErr == nil {
|
||||
return *cachedSysInfo, nil
|
||||
}
|
||||
return *cachedSysInfo, *cachedSysInfoErr
|
||||
}
|
||||
|
||||
|
|
|
@ -42,29 +42,27 @@ func megs(bytes uint64) int64 {
|
|||
}
|
||||
|
||||
// CachedHostInfo returns system information such as memory,CPU, DiskSize
|
||||
func CachedHostInfo() (*HostInfo, error) {
|
||||
i, err := cachedCPUInfo()
|
||||
if err != nil {
|
||||
glog.Warningf("Unable to get CPU info: %v", err)
|
||||
return nil, err
|
||||
func CachedHostInfo() (*HostInfo, error, error, error) {
|
||||
var cpuErr, memErr, diskErr error
|
||||
i, cpuErr := cachedCPUInfo()
|
||||
if cpuErr != nil {
|
||||
glog.Warningf("Unable to get CPU info: %v", cpuErr)
|
||||
}
|
||||
v, err := cachedSysMemLimit()
|
||||
if err != nil {
|
||||
glog.Warningf("Unable to get mem info: %v", err)
|
||||
return nil, err
|
||||
v, memErr := cachedSysMemLimit()
|
||||
if memErr != nil {
|
||||
glog.Warningf("Unable to get mem info: %v", memErr)
|
||||
}
|
||||
|
||||
d, err := cachedDiskInfo()
|
||||
if err != nil {
|
||||
glog.Warningf("Unable to get disk info: %v", err)
|
||||
return nil, err
|
||||
d, diskErr := cachedDiskInfo()
|
||||
if diskErr != nil {
|
||||
glog.Warningf("Unable to get disk info: %v", diskErr)
|
||||
}
|
||||
|
||||
var info HostInfo
|
||||
info.CPUs = len(i)
|
||||
info.Memory = megs(v.Total)
|
||||
info.DiskSize = megs(d.Total)
|
||||
return &info, nil
|
||||
return &info, cpuErr, memErr, diskErr
|
||||
}
|
||||
|
||||
// showLocalOsRelease shows systemd information about the current linux distribution, on the local host
|
||||
|
@ -111,20 +109,26 @@ func cachedSysMemLimit() (*mem.VirtualMemoryStat, error) {
|
|||
cachedSystemMemoryLimit = v
|
||||
cachedSystemMemoryErr = &err
|
||||
}
|
||||
if cachedSystemMemoryErr == nil {
|
||||
return cachedSystemMemoryLimit, nil
|
||||
}
|
||||
return cachedSystemMemoryLimit, *cachedSystemMemoryErr
|
||||
}
|
||||
|
||||
var cachedDisk *disk.UsageStat
|
||||
var cachedDiskInfoeErr *error
|
||||
var cachedDiskInfoErr *error
|
||||
|
||||
// cachedDiskInfo will return a cached disk usage info
|
||||
func cachedDiskInfo() (disk.UsageStat, error) {
|
||||
if cachedDisk == nil {
|
||||
d, err := disk.Usage("/")
|
||||
cachedDisk = d
|
||||
cachedDiskInfoeErr = &err
|
||||
cachedDiskInfoErr = &err
|
||||
}
|
||||
return *cachedDisk, *cachedDiskInfoeErr
|
||||
if cachedDiskInfoErr == nil {
|
||||
return *cachedDisk, nil
|
||||
}
|
||||
return *cachedDisk, *cachedDiskInfoErr
|
||||
}
|
||||
|
||||
var cachedCPU *[]cpu.InfoStat
|
||||
|
@ -136,9 +140,9 @@ func cachedCPUInfo() ([]cpu.InfoStat, error) {
|
|||
i, err := cpu.Info()
|
||||
cachedCPU = &i
|
||||
cachedCPUErr = &err
|
||||
if err != nil {
|
||||
return nil, *cachedCPUErr
|
||||
}
|
||||
}
|
||||
if cachedCPUErr == nil {
|
||||
return *cachedCPU, nil
|
||||
}
|
||||
return *cachedCPU, *cachedCPUErr
|
||||
}
|
||||
|
|
|
@ -254,8 +254,8 @@ func acquireMachinesLock(name string) (mutex.Releaser, error) {
|
|||
func showHostInfo(cfg config.ClusterConfig) {
|
||||
machineType := driver.MachineType(cfg.Driver)
|
||||
if driver.BareMetal(cfg.Driver) {
|
||||
info, err := CachedHostInfo()
|
||||
if err == nil {
|
||||
info, cpuErr, memErr, DiskErr := CachedHostInfo()
|
||||
if cpuErr == nil && memErr == nil && DiskErr == nil {
|
||||
register.Reg.SetStep(register.RunningLocalhost)
|
||||
out.T(out.StartingNone, "Running on localhost (CPUs={{.number_of_cpus}}, Memory={{.memory_size}}MB, Disk={{.disk_size}}MB) ...", out.V{"number_of_cpus": info.CPUs, "memory_size": info.Memory, "disk_size": info.DiskSize})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue