kubevirt: cpuAllocationRatio does not take effect

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

/kind bug I configured the value of cpuAllocationRatio in kubevirt CR, but it does not take effect.

kind: KubeVirt
metadata:
    name: kubevirt-kubevirt-hyperconverged
    namespace: kubevirt
spec:
    certificateRotateStrategy:
      selfSigned:
        ca:
          duration: 87600h0m0s
          renewBefore: 720h0m0s
        server:
          duration: 87600h0m0s
          renewBefore: 720h0m0s
    configuration:
      developerConfiguration:
        cpuAllocationRatio: 4
        diskVerification:
          memoryLimit: 2G
        featureGates:
        - DataVolumes
        - SRIOV
        - CPUManager
        - CPUNodeDiscovery
        - Snapshot
        - HotplugVolumes
        - ExpandDisks
        - GPU
        - HostDevices
        - DownwardMetrics
        - NUMA
        - WithHostModelCPU
        - HypervStrictCheck
        - SRIOVLiveMigration
      migrations:
        completionTimeoutPerGiB: 800
        parallelMigrationsPerCluster: 5
        parallelOutboundMigrationsPerNode: 2
        progressTimeout: 150
      network:
        defaultNetworkInterface: masquerade
      obsoleteCPUModels:
        "486": true
        Conroe: true
        athlon: true
        core2duo: true
        coreduo: true
        kvm32: true
        kvm64: true
        n270: true
        pentium: true
        pentium2: true
        pentium3: true
        pentiumpro: true
        phenom: true
        qemu32: true
        qemu64: true
      selinuxLauncherType: virt_launcher.process
      smbios:
        family: KubeVirt
        manufacturer: KubeVirt
        product: None
    customizeComponents: {}
    infra:
      replicas: 1
    uninstallStrategy: BlockUninstallIfWorkloadsExist
    workloadUpdateStrategy:
      batchEvictionInterval: 1m0s
      batchEvictionSize: 10
      workloadUpdateMethods:
      - LiveMigrate

Then I create the virtual machine, as defined in YAML:

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: test-vm
  namespace: test-ns
spec:
  template:
    spec:
      domain:
        cpu:
          cores: 12
        resources:
          limits:
            memory: 2Gi
          requests:
            memory: 2Gi

And then , the configuration you see in vmi looks like this:

apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  name: test-vm
  namespace: test-ns
spec:
  domain:
    cpu:
      cores: 12
      sockets: 1
      threads: 1
      model: host-model
    resources:
      limits:
        memory: 2Gi
      requests:
        memory: 2Gi

However, the resource.cpu value of the virt-launcher pod is always 1000m.

apiVersion: v1
kind: Pod
metadata:
  name: virt-launcher-test-vm-cnzxg
  namespace: test-ns
spec:
  containers:
  - name: compute
    resources:
      limits:
        cpu: "1"
        devices.kubevirt.io/kvm: "1"
        devices.kubevirt.io/tun: "1"
        devices.kubevirt.io/vhost-net: "1"
        memory: 2222Mi
      requests:
        cpu: "1"
        devices.kubevirt.io/kvm: "1"
        devices.kubevirt.io/tun: "1"
        devices.kubevirt.io/vhost-net: "1"
        ephemeral-storage: 50M
        memory: 2222Mi

But I think, according to Kubevirt’s code logic, pod cpu request value should be 12/4=3? Here is code https://github.com/kubevirt/kubevirt/blob/main/pkg/virt-controller/services/template.go#L883

What happened:

cpuAllocationRatio does not take effect

What you expected to happen:

cpuAllocationRatio take effect

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

  • KubeVirt version (use virtctl version): v0.48.1
  • Kubernetes version (use kubectl version): v1.22.3
  • VM or VMI specifications:
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): CentOS Linux 7
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (13 by maintainers)

Most upvoted comments

@dhiller I can have a look 😃