This message was deleted.
# harvester
a
This message was deleted.
b
What is the intended result you're after here? Are you hoping that the VM hotplugs more vCPU if there's sufficient idle resources?
p
@bored-painting-68221 I was actually looking whether
spec.domain.cpu.cores
takes precedence over limits but after reading docs I found that max cpu cores which can be used is bounded by
spec.domain.cpu.cores
Also I need one clarification I tried setting a
spec.domain.resources.limits[cpu] = 8
and
spec.domain.resources.Request[cpu] = 4
but when the VMI object is getting created , I observe both being set to equal to limits as shown below. Is it default behavior where harvester/kubevirt set resources.requets = resources.limits or am I missing anything here
b
Yes, that's to be expected. KubeVirt calculates vCPUs = sockets * cores * threads. If you define a limit, that overrides the sockets value to what the limit is. If you don't define a limit, but you define a request, that overrides the sockets value. If you define a request AND a limit, just the limit is used. So in your case, vcpus is calculated as 8 * 1 * 1 = 8 If you removed the limit, I'd guess it would be 4 * 1 * 1 = 4 https://github.com/kubevirt/kubevirt/blob/454907c4887b4d71f1929d7b46e93eaf1f558b58/pkg/virt-api/webhooks/defaults.go#L192 I also noticed the docs advise against specifying both .spec.domain.cpu and spec.domain.resources.[requests/limits] at the same time: https://kubevirt.io/user-guide/virtual_machines/dedicated_cpu_resources/#requesting-dedicated-cpu-resources Just as an FYI, as I haven't seen the YAML you are using.
p
@bored-painting-68221 Is there any way I can set
spec.domain.resources.limits[cpu] = 8
and
spec.domain.resources.Request[cpu] = 4
without requests being getting overwritten by limits ?
b
No
p
@bored-painting-68221 On a harvester cluster , I tried creating a VMI object with
spec.domain.resources.limits[cpu] = 8
and
spec.domain.resources.Request[cpu] = 4
but when the VMI object gets created ,
spec.domain.resources.limits[cpu] = spec.domain.resources.Request[cpu] = 8
. But when I updated the overcommit-config setting in Harvester UI from default (100% for cpu) to (200%)
Copy code
CPU : 200% 
Memory: 100%
Storage: 1000%
, the VMI object got created with desired
spec.domain.resources.limits[cpu] = 8
and
spec.domain.resources.Request[cpu] = 4
. Now what I want is to pass requests and limits say
spec.domain.resources.limits[cpu] = 7
and
spec.domain.resources.Request[cpu] = 5
in the VMI object and without overriding each other. How can this be done in harvester without updating the overcommit-config setting and on a per Virtual Machine level. I tried https://docs.harvesterhci.io/v1.2/vm/resource-overcommit/#configure-overcommit-for-a-single-virtual-machine but the requests gets overridden by limits if cpu % is set to 100 in overcommit-config setting. Moreover after looking into the harvester code , I found that there's a webhook (mutating webhook) which patches the incoming object (VMI)
spec.domain.resources.Requests.cpu
with value equal to `spec.domain.resources.Limits.cpu`https://github.com/harvester/harvester/blob/master/pkg/webhook/resources/virtualmachine/mutator.go#L198. Is there any way we can avoid this ?