Skip to content

Commit

Permalink
fix(kubevirt, core): inject-placement-anynode (#595)
Browse files Browse the repository at this point in the history
By default, the virtual-operator adds a nodePlacement with the RequireControlPlanePreferNonWorker.
But we set up the placement ourselves, so we replace the policy with AnyNode.
---------
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat authored Dec 19, 2024
1 parent fead0c5 commit 2e97ef5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
26 changes: 26 additions & 0 deletions images/virt-artifact/patches/028-inject-placement-anynode.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/pkg/virt-operator/resource/apply/apps.go b/pkg/virt-operator/resource/apply/apps.go
index 86a7e9cb5d..8554de9a05 100644
--- a/pkg/virt-operator/resource/apply/apps.go
+++ b/pkg/virt-operator/resource/apply/apps.go
@@ -51,7 +51,7 @@ func (r *Reconciler) syncDeployment(origDeployment *appsv1.Deployment) (*appsv1.

injectOperatorMetadata(kv, &deployment.ObjectMeta, imageTag, imageRegistry, id, true)
injectOperatorMetadata(kv, &deployment.Spec.Template.ObjectMeta, imageTag, imageRegistry, id, false)
- InjectPlacementMetadata(kv.Spec.Infra, &deployment.Spec.Template.Spec, RequireControlPlanePreferNonWorker)
+ InjectPlacementMetadata(kv.Spec.Infra, &deployment.Spec.Template.Spec, AnyNode)

if kv.Spec.Infra != nil && kv.Spec.Infra.Replicas != nil {
replicas := int32(*kv.Spec.Infra.Replicas)
diff --git a/pkg/virt-operator/strategy_job.go b/pkg/virt-operator/strategy_job.go
index df94c43bb1..b7ca869207 100644
--- a/pkg/virt-operator/strategy_job.go
+++ b/pkg/virt-operator/strategy_job.go
@@ -111,7 +111,7 @@ func (c *KubeVirtController) generateInstallStrategyJob(infraPlacement *v1.Compo
},
}

- apply.InjectPlacementMetadata(infraPlacement, &job.Spec.Template.Spec, apply.RequireControlPlanePreferNonWorker)
+ apply.InjectPlacementMetadata(infraPlacement, &job.Spec.Template.Spec, apply.AnyNode)
env := job.Spec.Template.Spec.Containers[0].Env
extraEnv := util.NewEnvVarMap(config.GetExtraEnv())
job.Spec.Template.Spec.Containers[0].Env = append(env, *extraEnv...)
5 changes: 5 additions & 0 deletions images/virt-artifact/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ How does it work?
2. When changing the affinity or nodeSelector in vmi, the vmi controller will set the `NodePlacementNotMatched` condition to True in vmi.
3. The workload-updater controller monitors the vmi and starts migration when there is a `NodePlacementNotMatched` conditions on the vmi.
4. When the migration is completed, virt-handler will remove the condition `NodePlacementNotMatched` from the vmi

#### `028-inject-placement-anynode.patch`

By default, the virtual-operator adds a nodePlacement with the RequireControlPlanePreferNonWorker.
But we set up the placement ourselves, so we replace the policy with AnyNode.

0 comments on commit 2e97ef5

Please sign in to comment.