Skip to content

Commit

Permalink
add more check for kvm2 support simulate numa node
Browse files Browse the repository at this point in the history
  • Loading branch information
phantooom committed Feb 22, 2021
1 parent eff3990 commit 8bd281a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func initDriverFlags() {
startCmd.Flags().String(kvmQemuURI, "qemu:///system", "The KVM QEMU connection URI. (kvm2 driver only)")
startCmd.Flags().Bool(kvmGPU, false, "Enable experimental NVIDIA GPU support in minikube")
startCmd.Flags().Bool(kvmHidden, false, "Hide the hypervisor signature from the guest in minikube (kvm2 driver only)")
startCmd.Flags().Int(kvmNUMACount, 1, "Simulate numa node count in minikube. (kvm2 driver only)")
startCmd.Flags().Int(kvmNUMACount, 1, "Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)")

// virtualbox
startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (virtualbox driver only)")
Expand Down Expand Up @@ -313,6 +313,19 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
out.WarningT("--network flag is only valid with the docker/podman drivers, it will be ignored")
}

if viper.GetInt(kvmNUMACount) < 1 || viper.GetInt(kvmNUMACount) > 8 {
exit.Message(reason.Usage, "--kvm-numa-count range is 1-8")
}
if viper.GetInt(kvmNUMACount) > 1 {
v, err := pkgutil.ParseKubernetesVersion(k8sVersion)
if err != nil {
exit.Message(reason.Usage, "invalid kubernetes version")
}
if v.LT(semver.Version{Major: 1,Minor: 18}){
exit.Message(reason.Usage, "numa node is only supported on k8s v1.18 and later")
}
}

cc = config.ClusterConfig{
Name: ClusterFlagValue(),
KeepContext: viper.GetBool(keepContext),
Expand Down
2 changes: 1 addition & 1 deletion pkg/drivers/kvm/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (d *Driver) Create() (err error) {
}

if d.NUMANodeCount > 1 {
NUMAXML, err := GetNUMAXml(d.CPU, d.Memory, d.NUMANodeCount)
NUMAXML, err := NumaXml(d.CPU, d.Memory, d.NUMANodeCount)
if err != nil {
return errors.Wrap(err, "creating NUMA XML")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/drivers/kvm/numa.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type NUMA struct {
CPUTopology string
}

// GetNUMAXml generate numa xml
// NumaXml generate numa xml
// evenly distributed cpu core & memory to each numa node
func GetNUMAXml(cpu, memory, numaCount int) (string, error) {
func NumaXml(cpu, memory, numaCount int) (string, error) {
if numaCount < 1 {
return "", fmt.Errorf("numa node count must >= 1")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/drivers/kvm/numa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
)

func TestGetNUMAXml(t *testing.T) {
_, err := GetNUMAXml(1, 1024, 0)
_, err := NumaXml(1, 1024, 0)
if err == nil {
t.Errorf("check invalid numa count failed: %s", err)
}

xml, err := GetNUMAXml(10, 10240, 8)
xml, err := NumaXml(10, 10240, 8)
expXML := `<numa>
<cell id='0' cpus='0,1' memory='1280' unit='MiB'/>
<cell id='1' cpus='2,3' memory='1280' unit='MiB'/>
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ minikube start [flags]
--kvm-gpu Enable experimental NVIDIA GPU support in minikube
--kvm-hidden Hide the hypervisor signature from the guest in minikube (kvm2 driver only)
--kvm-network string The KVM network name. (kvm2 driver only) (default "default")
--kvm-numa-count int Simulate numa node count in minikube. (kvm2 driver only) (default 1)
--kvm-numa-count int Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only) (default 1)
--kvm-qemu-uri string The KVM QEMU connection URI. (kvm2 driver only) (default "qemu:///system")
--memory string Amount of RAM to allocate to Kubernetes (format: <number>[<unit>], where unit = b, k, m or g).
--mount This will start the mount daemon and automatically mount files into minikube.
Expand Down

0 comments on commit 8bd281a

Please sign in to comment.