Bug 2004950 - Kubevirt doesn't respect cpuAllocationRatio
Summary: Kubevirt doesn't respect cpuAllocationRatio
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Virtualization
Version: 4.8.1
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: 4.8.4
Assignee: Vladik Romanovsky
QA Contact: Kedar Bidarkar
URL:
Whiteboard:
Depends On: 2002313
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-16 13:39 UTC by Kedar Bidarkar
Modified: 2022-10-17 13:14 UTC (History)
7 users (show)

Fixed In Version: virt-operator-container-v4.8.4-4 hco-bundle-registry-container-v4.8.4-11
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2002313
Environment:
Last Closed: 2022-01-20 17:21:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt kubevirt pull 6655 0 None Merged [release-0.41] Fix the default setting of CPU requests on vmipods 2021-11-03 12:23:12 UTC
Red Hat Knowledge Base (Solution) 6980540 0 None None None 2022-10-17 13:13:57 UTC
Red Hat Product Errata RHBA-2022:0213 0 None None None 2022-01-20 17:21:33 UTC

Description Kedar Bidarkar 2021-09-16 13:39:43 UTC
+++ This bug was initially created as a clone of Bug #2002313 +++

Description of problem:


I installed OpenShift Virtualization 4.8.1 and created different VMs with different specs. I used different numbers for cpu core field. However, Kubevirt doesn't change the requested cpu amount in virt-launcher spec. It was always 100m. 

Version-Release number of selected component (if applicable): 4.8.1


Actual results:
All virt-launcher pods contains the same amount of cpu. 100m


Expected results: It should be proportional to VM spec as explained here: http://kubevirt.io/user-guide/operations/node_overcommit/#node-cpu-allocation-ratio


Additional info: HCO is not setting cpuAllocationRatio in Kubevirt and it is empty by default.

--- Additional comment from Kedar Bidarkar on 2021-09-08 18:45:46 UTC ---

Tried to reproduce this:

a) Explicitly set the "cpuAllocationRatio" value via the JSON Annotation Patch.

]$ oc annotate --overwrite -n openshift-cnv hyperconverged kubevirt-hyperconverged kubevirt.kubevirt.io/jsonpatch='[{
      "op": "add",
      "path": "/spec/configuration/developerConfiguration/cpuAllocationRatio",
      "value": 20
  }]'

b) Value appears set correctly

]$ oc get kubevirt kubevirt-kubevirt-hyperconverged -n openshift-cnv -o yaml | grep -A 5 "configuration:"
  configuration:
    developerConfiguration:
      cpuAllocationRatio: 20
      diskVerification:
        memoryLimit: 2G
      featureGates:

c) I had set the "cores" count under "cpu" as 6
]$ oc get vmi vm22-rhel84-ocs -o yaml | grep -A 5 "cpu:"
    cpu:
      cores: 6
      sockets: 1
      threads: 1
---

d) virt-launcher pod shows "cpu: 100m" 

]$ oc get pod virt-launcher-vm22-rhel84-ocs-sv46l -o yaml | grep "cpu:"
        cpu: 100m

POD CPU request = number of vCPUs * 1/cpuAllocationRatio

Probably the expected value should have been  6/20 = 330m or 300m , IIUC

---
e) 
Logged into the VM and checked for the nproc value. It is indeed 6.

[cloud-user@vm22-rhel84-ocs ~]$ nproc
6

--- Additional comment from Kedar Bidarkar on 2021-09-08 18:47:41 UTC ---

comment1 stuff was reproduced on CNV-4.9.0.

--- Additional comment from Vladik Romanovsky on 2021-09-13 15:30:09 UTC ---

I've posted https://github.com/kubevirt/kubevirt/pull/6374 to fix this.

Comment 1 sgott 2021-09-22 12:25:50 UTC
backport tracked here:
https://github.com/kubevirt/kubevirt/pull/6453

Comment 3 Roman Mohr 2021-10-21 12:42:39 UTC
Backport is merged.

Comment 5 sgott 2021-11-03 12:23:13 UTC
Manual backport supercedes previous PR: https://github.com/kubevirt/kubevirt/pull/6655

Comment 6 Kedar Bidarkar 2021-12-14 20:58:28 UTC
]$ oc annotate --overwrite -n openshift-cnv hyperconverged kubevirt-hyperconverged kubevirt.kubevirt.io/jsonpatch='[{
>       "op": "add",
>       "path": "/spec/configuration/developerConfiguration/cpuAllocationRatio",
>       "value": 20
>   }]'
hyperconverged.hco.kubevirt.io/kubevirt-hyperconverged annotated


]$ oc get vmi vm-rhel84-ocs -o yaml | grep -A 5 "cpu:"
    cpu:
      cores: 6
      sockets: 1
      threads: 1

]$ oc get pods
NAME                                READY   STATUS    RESTARTS   AGE
virt-launcher-vm-rhel84-ocs-94lpm   1/1     Running   0          3m41s

]$ oc get pod virt-launcher-vm-rhel84-ocs-94lpm -o yaml | grep "cpu:"
                f:cpu: {}
        cpu: 300m
---


VERIFIED with,  virt-operator/images/v4.8.4-4

Comment 13 errata-xmlrpc 2022-01-20 17:21:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Virtualization 4.8.4 Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:0213


Note You need to log in before you can comment on or make changes to this bug.