Change KubeVirt VM CPU assignment to not overwrite cpu alloc ratio#1906
Change KubeVirt VM CPU assignment to not overwrite cpu alloc ratio#1906kubermatic-bot merged 7 commits intokubermatic:mainkubermatic/machine-controller:mainfrom soer3n:change-kubevirt-vm-resource-assignmentsoer3n/machine-controller:change-kubevirt-vm-resource-assignmentCopy head branch name to clipboard
Conversation
Signed-off-by: soer3n <srenhenning@googlemail.com>
e072ff1 to
4d4b946
Compare
Signed-off-by: soer3n <srenhenning@googlemail.com>
344510c to
33ead46
Compare
Signed-off-by: soer3n <srenhenning@googlemail.com>
33ead46 to
0a2e73c
Compare
| if isDedicatedVCPURequested(machine.Spec.Annotations) { | ||
| cpusAsUint64, err := strconv.ParseUint(c.CPUs, 0, 64) | ||
|
|
||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to parse cpu cores: %w", err) | ||
| } | ||
|
|
||
| virtualMachine.Spec.Template.Spec.Domain.CPU = &kubevirtcorev1.CPU{ | ||
| Cores: uint32(cpusAsUint64), | ||
| } | ||
| } |
There was a problem hiding this comment.
If this annotation is consumed in machine-controller then this should be configured at machine.Annotations not in the spec.
sdk/cloudprovider/kubevirt/types.go
Outdated
| ) | ||
|
|
||
| const ( | ||
| UseDedicatedKubevirtVCPUAnnotationKey = "kubermatic.io/use-dedicated-kubevirt-cpu" |
There was a problem hiding this comment.
| UseDedicatedKubevirtVCPUAnnotationKey = "kubermatic.io/use-dedicated-kubevirt-cpu" | |
| UseDedicatedKubeVirtVCPUAnnotationKey = "kubermatic.io/use-dedicated-kubevirt-cpu" |
|
|
||
| if isDedicatedVCPURequested(machine.Spec.Annotations) { | ||
| cpusAsUint64, err := strconv.ParseUint(c.CPUs, 0, 64) | ||
|
|
There was a problem hiding this comment.
No need for space here
|
sdk/cloudprovider/kubevirt/types.go
Outdated
| ) | ||
|
|
||
| const ( | ||
| UseDedicatedKubevirtVCPUAnnotationKey = "kubermatic.io/use-dedicated-kubevirt-cpu" |
There was a problem hiding this comment.
I think it is better if you actually use the RawConfig instead of annotations.
Signed-off-by: soer3n <srenhenning@googlemail.com>
* adapt kubevirt cpu struct for configuring vcpus for a virtual machine * modify logic in function for rendering resource requests and limits * modify validation accordingly to be a bit more specific regarding resources Signed-off-by: soer3n <srenhenning@googlemail.com>
Signed-off-by: soer3n <srenhenning@googlemail.com>
2162ddc to
8b52fcc
Compare
|
@ahmedwaleedmalik I changed the kind to feature and modified the release notes accordingly to the changes i added after discussing the implementation with @moadqassem. |
| if (c.VCPUs == nil && c.Resources.Cpu() == nil) || (c.VCPUs != nil && c.Resources.Cpu() != nil) { | ||
| return fmt.Errorf("invalid/no cpus configured. Either vpus or cpus have to be configured.") |
There was a problem hiding this comment.
The error message here is quite misleading since in cases where both vCPU and CPU are set, you are still returning the same message. Please split this into two different if blocks or be a bit more coherent with your error message.
There was a problem hiding this comment.
Thanks for the suggestion. I separated both conditions and changed the return message to be a bit more clearer.
sdk/cloudprovider/kubevirt/types.go
Outdated
| Sockets int `json:"sockets,omitempty"` | ||
| Threads int `json:"threads,omitempty"` |
There was a problem hiding this comment.
Both Sockets and Threads are unused. We should either remove these variables or utilize them at
andmachine-controller/pkg/cloudprovider/provider/kubevirt/provider.go
Lines 854 to 856 in 8b52fcc
There was a problem hiding this comment.
I removed the unused values and only left cores for now.
|
Looks much better as part of the providerconfig 🚀 Same feedback as the first point from #1906 (comment), in release note please explicitly mention the "new field" that you have introduced i.e. |
cd442fb to
2d40bf8
Compare
Signed-off-by: soer3n <srenhenning@googlemail.com>
2d40bf8 to
966a390
Compare
|
LGTM label has been added. DetailsGit tree hash: 997ea22ccf2bb767bf1bf0be0f7c512163f0e8e8 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmedwaleedmalik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherrypick release/v1.61 |
|
@soer3n: #1906 failed to apply on top of branch "release/v1.61": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…ubermatic#1906) * change kubevirt vm cpu assignment to not overwrite cpu alloc ratio Signed-off-by: soer3n <srenhenning@googlemail.com> * update kubevirt testdata Signed-off-by: soer3n <srenhenning@googlemail.com> * revert testdata change and add condition for vm cpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * switch to providerSpec for enabling vcpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * adapt kubevirt cpu struct * adapt kubevirt cpu struct for configuring vcpus for a virtual machine * modify logic in function for rendering resource requests and limits * modify validation accordingly to be a bit more specific regarding resources Signed-off-by: soer3n <srenhenning@googlemail.com> * revert unnessecarry changes to mocked kubevirt vm Signed-off-by: soer3n <srenhenning@googlemail.com> * changes after review Signed-off-by: soer3n <srenhenning@googlemail.com> --------- Signed-off-by: soer3n <srenhenning@googlemail.com>
…ubermatic#1906) * change kubevirt vm cpu assignment to not overwrite cpu alloc ratio Signed-off-by: soer3n <srenhenning@googlemail.com> * update kubevirt testdata Signed-off-by: soer3n <srenhenning@googlemail.com> * revert testdata change and add condition for vm cpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * switch to providerSpec for enabling vcpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * adapt kubevirt cpu struct * adapt kubevirt cpu struct for configuring vcpus for a virtual machine * modify logic in function for rendering resource requests and limits * modify validation accordingly to be a bit more specific regarding resources Signed-off-by: soer3n <srenhenning@googlemail.com> * revert unnessecarry changes to mocked kubevirt vm Signed-off-by: soer3n <srenhenning@googlemail.com> * changes after review Signed-off-by: soer3n <srenhenning@googlemail.com> --------- Signed-off-by: soer3n <srenhenning@googlemail.com>
* Change KubeVirt VM CPU assignment to not overwrite cpu alloc ratio (#1906) * change kubevirt vm cpu assignment to not overwrite cpu alloc ratio Signed-off-by: soer3n <srenhenning@googlemail.com> * update kubevirt testdata Signed-off-by: soer3n <srenhenning@googlemail.com> * revert testdata change and add condition for vm cpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * switch to providerSpec for enabling vcpu assignment Signed-off-by: soer3n <srenhenning@googlemail.com> * adapt kubevirt cpu struct * adapt kubevirt cpu struct for configuring vcpus for a virtual machine * modify logic in function for rendering resource requests and limits * modify validation accordingly to be a bit more specific regarding resources Signed-off-by: soer3n <srenhenning@googlemail.com> * revert unnessecarry changes to mocked kubevirt vm Signed-off-by: soer3n <srenhenning@googlemail.com> * changes after review Signed-off-by: soer3n <srenhenning@googlemail.com> --------- Signed-off-by: soer3n <srenhenning@googlemail.com> * fix kubevirt cpu check + update sdk version in go.mod Signed-off-by: soer3n <srenhenning@googlemail.com> revert change regarding import of sdk submodule Signed-off-by: soer3n <srenhenning@googlemail.com> kubevirt resources and vcpus should only be parsed wihtout specified instance type Signed-off-by: soer3n <srenhenning@googlemail.com> --------- Signed-off-by: soer3n <srenhenning@googlemail.com>
What this PR does / why we need it:
This pr changes the assignment of cpu resources for kubevirt virtual machines to be able to use kubevirt
cpuAllocationRatiofeature by introducing a new field to the providerSpec called vCPUs.Which issue(s) this PR fixes:
Fixes #1905
What type of PR is this?
/kind feature
Special notes for your reviewer:
Does this PR introduce a user-facing change? Then add your Release Note here:
Documentation: