Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neonvm: add architecture field to vm.spec #1244

Merged
merged 7 commits into from
Feb 11, 2025

Conversation

mikhail-sakhnov
Copy link
Contributor

Add spec.cpuArchitecture to use for scheduling pods instead of relying on spec.affinity.
Use spec.cpuArchitecture value while building the vm pod spec affinity.

Extracted from #1123

Copy link

github-actions bot commented Feb 4, 2025

No changes to the coverage.

HTML Report

Click to open

@mikhail-sakhnov mikhail-sakhnov marked this pull request as ready for review February 4, 2025 14:01
@sharnoff sharnoff self-assigned this Feb 4, 2025
Copy link
Member

@sharnoff sharnoff left a comment

Choose a reason for hiding this comment

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

Just a couple thoughts

neonvm/apis/neonvm/v1/virtualmachine_types.go Outdated Show resolved Hide resolved
@sharnoff sharnoff assigned mikhail-sakhnov and unassigned sharnoff Feb 4, 2025
@mikhail-sakhnov mikhail-sakhnov force-pushed the misha/add-explicit-architecture-field branch from d4a3a0c to fddedb6 Compare February 4, 2025 15:29
@sharnoff sharnoff assigned mikhail-sakhnov and unassigned sharnoff Feb 7, 2025
@mikhail-sakhnov mikhail-sakhnov force-pushed the misha/add-explicit-architecture-field branch 2 times, most recently from 8ace4b1 to 4cb7904 Compare February 10, 2025 16:24
@sharnoff
Copy link
Member

sharnoff commented Feb 10, 2025

Sorry, a couple higher level things I realized w.r.t. rollout:

  1. What happens to old VMs? Will k8s automatically default them to the new behavior? How will we make sure that they continue to get x86 if they restart?
  2. What happens on rollback?

Given these: Maybe worthwhile to (a) remove the CRD default to x86, and (b) interpret nil as x86, until all clients have been updated? And then we can update all VM objects to set TargetArchitecture to x86 and change the controller to have nil handling in the way that we want.


Again, sorry for not realizing this sooner -- backwards/forwards compatibility can be really tricky to get right with this kind of thing.

@sharnoff sharnoff assigned mikhail-sakhnov and unassigned sharnoff Feb 10, 2025
@mikhail-sakhnov mikhail-sakhnov force-pushed the misha/add-explicit-architecture-field branch from 7abc591 to c4a50d1 Compare February 11, 2025 06:30
@mikhail-sakhnov
Copy link
Contributor Author

@sharnoff

What happens to old VMs? Will k8s automatically default them to the new behavior? How will we make sure that they continue to get x86 if they restart?

So in general, the old VMs have no materialized value for the field in the kube-api storage. When deploying a version with spec.targetArchitecture annotated with "kubebuilder:default:amd64", the lack of the set value will be interpreted as "amd64".

Indeed, if we rollback to the version without spec.targetArchitecture, the behaviour would be to ignore spec.targetArchutecture even if it is materialized in the kube-api storage. In practice, that would lead to always create a pod with nodeArchitecture affinity equal controller architecture.

If it feels safer, I changed the default value for spec.targetArchitecture to be nil and add code to explicitly set it to amd64 in vm_controller.go, by this we will have materialized values for all VMs after at least reconciliation.

However, in case of rollback, it doesn't change anything, since if we rollback, we rollback to the version which has no spec.targetArchitecture and function affinityForVirtualMachine will behave based on the controller architecture.

Did I answer your question, or should I elaborate deeper on something?

@mikhail-sakhnov mikhail-sakhnov force-pushed the misha/add-explicit-architecture-field branch from 54ed3b1 to fff8d1e Compare February 11, 2025 07:42
Copy link
Member

@sharnoff sharnoff left a comment

Choose a reason for hiding this comment

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

Looks good, modulo two comments

pkg/neonvm/controllers/vm_controller.go Outdated Show resolved Hide resolved
pkg/neonvm/controllers/vm_controller.go Outdated Show resolved Hide resolved
Add spec.cpuArchitecture to use for scheduling
pods instead of relying on spec.affinity.
Add new field to the kubectl output.
Set target architecture to amd64 while reconciling VM
if the current value is nil. This is required to materialize the default
value in storage for currently running VMs.
@mikhail-sakhnov mikhail-sakhnov force-pushed the misha/add-explicit-architecture-field branch from b3d54c4 to 33615ae Compare February 11, 2025 12:08
@mikhail-sakhnov mikhail-sakhnov merged commit 76b4c15 into main Feb 11, 2025
23 checks passed
@mikhail-sakhnov mikhail-sakhnov deleted the misha/add-explicit-architecture-field branch February 11, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants