Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lyarwood
Copy link
Member

@lyarwood lyarwood commented Aug 7, 2025

/area instancetype

What this PR does

Preferences are now able to express both preferred and required architecture values for VirtualMachines.

References

Why we need it and why it was done in this way

The following tradeoffs were made:

The following alternatives were considered:

Links to places where the discussion took place:

Special notes for your reviewer

Depends on #15009 as we will also need to handle the defaulting in the mutation webhook.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

Preferences can now express preferred and required architecture values for use within VirtualMachines

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. area/instancetype dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/compute labels Aug 7, 2025
@lyarwood lyarwood changed the title WIP/DNM - Introduce PreferredArchitecture and Architecture requirements to preferences Introduce PreferredArchitecture and Architecture requirements to preferences Sep 10, 2025
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Sep 10, 2025
@lyarwood lyarwood marked this pull request as ready for review September 10, 2025 12:35
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 10, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Wrap the Architecture requirement check inside the same Requirements != nil guard in checker.go to avoid dereferencing Requirements when it’s nil and causing a panic.
  • There’s a typo in the field descriptions (prefeerred); please correct it to preferred for consistency.
  • Rather than hand‐editing the generated CRD and client-go OpenAPI files, consider updating the generator definitions and rerunning the codegen so future changes don’t get overwritten.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Wrap the Architecture requirement check inside the same `Requirements != nil` guard in checker.go to avoid dereferencing `Requirements` when it’s nil and causing a panic.
- There’s a typo in the field descriptions (`prefeerred`); please correct it to `preferred` for consistency.
- Rather than hand‐editing the generated CRD and client-go OpenAPI files, consider updating the generator definitions and rerunning the codegen so future changes don’t get overwritten.

## Individual Comments

### Comment 1
<location> `pkg/virt-operator/resource/generate/components/validations_generated.go:9827` </location>
<code_context>
           format: int32
           type: integer
+        preferredArchitecture:
+          description: PreferredArchitecture defines a prefeerred architecture for
+            the VirtualMachine
+          type: string
</code_context>

<issue_to_address>
Typo in 'prefeerred' in description.

Please update the description to use the correct spelling: 'preferred'.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
          description: PreferredArchitecture defines a prefeerred architecture for
            the VirtualMachine
=======
          description: PreferredArchitecture defines a preferred architecture for
            the VirtualMachine
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lyarwood lyarwood force-pushed the preference-arch branch 3 times, most recently from ab9118a to 35b7b8e Compare September 10, 2025 14:04
@lyarwood
Copy link
Member Author

/hold #15009

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2025
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 26, 2025
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 29, 2025
@lyarwood
Copy link
Member Author

/hold cancel
/cc @0xFelix
/cc @jcanocan

Would you both mind taking a look at this, I'd like to introduce use of it to common-instancetypes for this release if possible.

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 29, 2025
@jcanocan
Copy link
Contributor

Great job! Thanks!
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2025
}

preferenceSpec, _ := m.FindPreference(vm)
mutateArch(vm, preferenceSpec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be mutating the VM. Is it not sufficient to apply the architecture when a VMI is created from the VM and preference?

Copy link
Member Author

@lyarwood lyarwood Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xFelix Unfortunately we always mutate a default arch into the VM so we have no choice but mutate any preferred values ahead of this to ensure they apply. I'd much rather this wasn't the case and we could just override defaults through a status value but refactoring and changing this behaviour is lots of work and outside the scope of this PR tbh. For now this will have to do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, unfortunate but it is what it is.

@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2025
Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Thanks!

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2025
Copy link
Contributor

@jean-edouard jean-edouard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/hold
See in-line comments about formatting/typo. Feel free to unhold.

//+optional
PreferSpreadSocketToCoreRatio uint32 `json:"preferSpreadSocketToCoreRatio,omitempty"`

// PreferredArchitecture defines a prefeerred architecture for the VirtualMachine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo prefeerred

Comment on lines +17 to +19
*
*/
package apply
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
*/
package apply
*/
package apply

Comment on lines +17 to +19
*
*/
package requirements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
*/
package requirements
*/
package requirements

* limitations under the License.
*
* Copyright The KubeVirt Authors.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*/
*/

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 3, 2025
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jean-edouard

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2025
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-k8s-1.34-windows2016
/test pull-kubevirt-e2e-kind-1.33-vgpu
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.33-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.32-sig-network
/test pull-kubevirt-e2e-k8s-1.32-sig-storage
/test pull-kubevirt-e2e-k8s-1.32-sig-compute
/test pull-kubevirt-e2e-k8s-1.32-sig-operator
/test pull-kubevirt-e2e-k8s-1.33-sig-network
/test pull-kubevirt-e2e-k8s-1.33-sig-storage
/test pull-kubevirt-e2e-k8s-1.33-sig-compute
/test pull-kubevirt-e2e-k8s-1.33-sig-operator

@lyarwood
Copy link
Member Author

lyarwood commented Oct 3, 2025

/hold cancel

Thanks @jean-edouard I'll clean this up in a follow up PR

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 3, 2025
@kubevirt-commenter-bot
Copy link

/retest-required
This bot automatically retries required jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Oct 3, 2025

@lyarwood: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-goveralls 402cca3 link false /test pull-kubevirt-goveralls
pull-kubevirt-e2e-k8s-1.33-sig-compute-arm64 402cca3 link false /test pull-kubevirt-e2e-k8s-1.33-sig-compute-arm64
pull-kubevirt-e2e-k8s-1.34-sig-compute-serial 402cca3 link unknown /test pull-kubevirt-e2e-k8s-1.34-sig-compute-serial
Details

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. I understand the commands that are listed here.

@kubevirt-bot kubevirt-bot merged commit 69b8ef8 into kubevirt:main Oct 4, 2025
43 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/instancetype dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/compute size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants