kubernetes / minikube

Run Kubernetes locally
https://minikube.sigs.k8s.io/
Apache License 2.0
29.35k stars 4.88k forks source link

minikube on 1 CPUs on Travis work with "--force" and also reports 2 Cpus #10260

Closed medyagh closed 3 years ago

medyagh commented 3 years ago

interesting that when we not using --force minikube exits on Travis and says it only has 1 Cpus

+sudo minikube start --vm-driver=none
* minikube v1.17.0 on Ubuntu 18.04 (kvm/amd64)
* Using the none driver based on user configuration
X Exiting due to RSRC_INSUFFICIENT_CORES: Requested cpu count 1 is less than the minimum allowed of 2

but when user uses --force it is reporting 2 local cpus

* Running on localhost (CPUs=2, Memory=7961MB, Disk=69295MB) ...

the confusing part is, if it really has 1 cpus, then why we are reporting 2 cpus later ?

here is the setup script on travis

https://github.com/GoogleContainerTools/kaniko/blob/5f4e2f136633d241444129517a4e75ebf44065c7/scripts/minikube-setup.sh#L30


cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 85
model name  : Intel(R) Xeon(R) CPU
stepping    : 7
microcode   : 0x1
cpu MHz     : 2800.204
cache size  : 33792 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat avx512_vnni md_clear arch_capabilities
bugs        : spectre_v1 spectre_v2 spec_store_bypass mds swapgs taa
bogomips    : 5600.40
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:
processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 85
model name  : Intel(R) Xeon(R) CPU
stepping    : 7
microcode   : 0x1
cpu MHz     : 2800.204
cache size  : 33792 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat avx512_vnni md_clear arch_capabilities
bugs        : spectre_v1 spectre_v2 spec_store_bypass mds swapgs taa
bogomips    : 5600.40
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:
+sudo minikube start --vm-driver=none --force
* minikube v1.17.0 on Ubuntu 18.04 (kvm/amd64)
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Using the none driver based on user configuration
X Requested cpu count 1 is less than the minimum allowed of 2
* Starting control plane node minikube in cluster minikube
* Running on localhost (CPUs=2, Memory=7961MB, Disk=69295MB) ...
* OS release is Ubuntu 18.04.5 LTS
* Preparing Kubernetes v1.20.2 on Docker 20.10.2 ...
  - kubelet.resolv-conf=/run/systemd/resolve/resolv.conf
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 37.40 MiB / 37.40 MiB [--------------] 100.00% 418.44 MiB p/s 0s
    > kubectl: 38.37 MiB / 38.37 MiB [--------------] 100.00% 525.11 MiB p/s 0s
    > kubelet: 108.73 MiB / 108.73 MiB [------------] 100.00% 301.81 MiB p/s 0s
  - Generating certificates and keys .../ - \ | / 
  - Booting up control plane ...- \ | / - \ | / - \ | / - \ | / - \ | / - \ | 
  - Configuring RBAC rules .../ - 
* Configuring local host environment ...
* ```
tejal29 commented 3 years ago

Interesting!

afbjorklund commented 3 years ago

This is because one part of the code includes hyperthreads, and another part does not...

cpu.Counts(false)

https://godoc.org/github.com/shirou/gopsutil/cpu#Counts

len(cpu.Info())

https://godoc.org/github.com/shirou/gopsutil/cpu#Info

Kubeadm is not very specific, if it requires 2 threads/vCPUs or 2 hardware cores/"things".

"2 CPUs or more"

Most likely that "false" should be flipped to "true" ?

afbjorklund commented 3 years ago

Seems like the behaviour changed, between cpu and v3/cpu:

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/cpu"
)

func main() {
    physical, _ := cpu.Counts(false)
    fmt.Printf("Physical: %d\n", physical)
    logical, _ := cpu.Counts(true)
    fmt.Printf("Logical: %d\n", logical)
}

This reports 8/8 on quad core, but with v3 it now reports 4/8.

$ lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   39 bits physical, 48 bits virtual
CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2
Core(s) per socket:              4
Socket(s):                       1
...

See https://github.com/shirou/gopsutil/commit/770026217560bdd8b941da6326c702d28a44c361