From babcf51899754cebeb72402c421d51eb788c18c1 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 10 Aug 2020 14:33:46 -0700 Subject: [PATCH] return list of errors for cached host info --- cmd/minikube/cmd/start.go | 4 ++-- pkg/minikube/machine/info.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 6ed389d6b1eb..78bbfef22889 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -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 @@ -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) } diff --git a/pkg/minikube/machine/info.go b/pkg/minikube/machine/info.go index 15e94558c7d7..e15e2363a76c 100644 --- a/pkg/minikube/machine/info.go +++ b/pkg/minikube/machine/info.go @@ -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 }