Skip to content

Commit 1217054

Browse files
committed
Updated cpu check to handle none driver cpu check
1 parent 3e07731 commit 1217054

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cmd/minikube/cmd/start.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
"k8s.io/minikube/pkg/util/lock"
6161
"k8s.io/minikube/pkg/util/retry"
6262
"k8s.io/minikube/pkg/version"
63+
"github.com/shirou/gopsutil/cpu"
6364
)
6465

6566
const (
@@ -538,7 +539,16 @@ func validateConfig() {
538539
out.V{"memory": memorySizeMB, "default_memorysize": pkgutil.CalculateSizeInMB(constants.DefaultMemorySize)})
539540
}
540541

541-
cpuCount = viper.GetInt(cpus)
542+
if viper.GetString(vmDriver) == constants.DriverNone {
543+
ci, err := cpu.Info()
544+
if err != nil {
545+
glog.Warningf("Unable to get CPU info: $v", err)
546+
} else {
547+
cpuCount = ci.Cores
548+
}
549+
} else {
550+
cpuCount = viper.GetInt(cpus)
551+
}
542552
if cpuCount < constants.MinimumCPUS {
543553
exit.UsageT("Requested cpu count {{.requested_cpus}} is less than the minimum allowed of {{.minimum_cpus}}", out.V{"requested_cpus": cpuCount, "minimum_cpus": constants.MinimumCPUS})
544554
}

0 commit comments

Comments
 (0)