Skip to content

Commit 0690a4d

Browse files
committed
fix(vm): sync unschedulable KVVM on vmclass placement change
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent ab6c6c2 commit 0690a4d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

images/virtualization-artifact/pkg/controller/vm/internal/sync_kvvm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ func (h *SyncKvvmHandler) isVMUnschedulable(
717717
func (h *SyncKvvmHandler) isPlacementPolicyChanged(allChanges vmchange.SpecChanges) bool {
718718
for _, c := range allChanges.GetAll() {
719719
switch c.Path {
720-
case "affinity", "nodeSelector", "tolerations":
720+
case "affinity", "nodeSelector", "tolerations", "virtualMachineClassName", "VirtualMachineClass:spec.nodeSelector", "VirtualMachineClass:spec.tolerations":
721721
if !equality.Semantic.DeepEqual(c.CurrentValue, c.DesiredValue) {
722722
return true
723723
}

images/virtualization-artifact/pkg/controller/vm/internal/sync_kvvm_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/deckhouse/virtualization-controller/pkg/controller/reconciler"
3535
vmservice "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/service"
3636
"github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/state"
37+
"github.com/deckhouse/virtualization-controller/pkg/controller/vmchange"
3738
"github.com/deckhouse/virtualization-controller/pkg/eventrecord"
3839
"github.com/deckhouse/virtualization/api/core/v1alpha2"
3940
"github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition"
@@ -319,4 +320,19 @@ var _ = Describe("SyncKvvmHandler", func() {
319320
Entry("Pending phase with changes applied, condition should not exist", v1alpha2.MachinePending, false, metav1.ConditionUnknown, false),
320321
Entry("Pending phase with changes not applied, condition should not exist", v1alpha2.MachinePending, true, metav1.ConditionUnknown, false),
321322
)
323+
324+
DescribeTable("isPlacementPolicyChanged",
325+
func(path string, expected bool) {
326+
h := &SyncKvvmHandler{}
327+
changes := vmchange.SpecChanges{}
328+
changes.Add(vmchange.FieldChange{Path: path, CurrentValue: "old", DesiredValue: "new"})
329+
330+
Expect(h.isPlacementPolicyChanged(changes)).To(Equal(expected))
331+
},
332+
Entry("vm tolerations change", "tolerations", true),
333+
Entry("vmclass tolerations change", "VirtualMachineClass:spec.tolerations", true),
334+
Entry("vmclass nodeSelector change", "VirtualMachineClass:spec.nodeSelector", true),
335+
Entry("vmclass name change", "virtualMachineClassName", true),
336+
Entry("cpu change is not a placement policy", "cpu.cores", false),
337+
)
322338
})

0 commit comments

Comments
 (0)