Skip to content

Commit

Permalink
return list of errors for cached host info
Browse files Browse the repository at this point in the history
  • Loading branch information
medyagh committed Aug 10, 2020
1 parent 7e1dd0e commit babcf51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ 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) {
func memoryLimits(drvName string) (int, int, []error) {
info, err := machine.CachedHostInfo()
if err != nil {
return -1, -1, err
Expand All @@ -775,7 +775,7 @@ func memoryLimits(drvName string) (int, int, error) {
if driver.IsKIC(drvName) {
s, err := oci.CachedDaemonInfo(drvName)
if err != nil {
return -1, -1, err
return -1, -1, []error{err}
}
containerLimit = int(s.TotalMemory / 1024 / 1024)
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/minikube/machine/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,32 @@ func megs(bytes uint64) int64 {
}

// CachedHostInfo returns system information such as memory,CPU, DiskSize
func CachedHostInfo() (*HostInfo, error) {
func CachedHostInfo() (*HostInfo, []error) {
var hostInfoErrs []error
i, err := cachedCPUInfo()
if err != nil {
glog.Warningf("Unable to get CPU info: %v", err)
return nil, err
hostInfoErrs = append(hostInfoErrs, err)
}
v, err := cachedSysMemLimit()
if err != nil {
glog.Warningf("Unable to get mem info: %v", err)
return nil, err
hostInfoErrs = append(hostInfoErrs, err)
}

d, err := cachedDiskInfo()
if err != nil {
glog.Warningf("Unable to get disk info: %v", err)
return nil, err
hostInfoErrs = append(hostInfoErrs, err)
}

var info HostInfo
info.CPUs = len(i)
info.Memory = megs(v.Total)
info.DiskSize = megs(d.Total)
if len(hostInfoErrs) > 0 {
return &info, hostInfoErrs
}
return &info, nil
}

Expand Down

0 comments on commit babcf51

Please sign in to comment.