diff --git a/images/virtualization-artifact/pkg/controller/vmchange/comparator_block_devices.go b/images/virtualization-artifact/pkg/controller/vmchange/comparator_block_devices.go index 4405077068..a1b2226329 100644 --- a/images/virtualization-artifact/pkg/controller/vmchange/comparator_block_devices.go +++ b/images/virtualization-artifact/pkg/controller/vmchange/comparator_block_devices.go @@ -27,6 +27,10 @@ const blockDevicesPath = "blockDeviceRefs" // compareBlockDevices returns changes between current and desired blockDevices lists. func compareBlockDevices(current, desired *v1alpha2.VirtualMachineSpec) []FieldChange { + if current.EnableParavirtualization && desired.EnableParavirtualization { + return nil + } + if len(current.BlockDeviceRefs) == 0 && len(desired.BlockDeviceRefs) == 0 { return nil } diff --git a/images/virtualization-artifact/pkg/controller/vmchange/compare_test.go b/images/virtualization-artifact/pkg/controller/vmchange/compare_test.go index 8377ac10fa..e190205987 100644 --- a/images/virtualization-artifact/pkg/controller/vmchange/compare_test.go +++ b/images/virtualization-artifact/pkg/controller/vmchange/compare_test.go @@ -281,7 +281,7 @@ blockDeviceRefs: ), }, { - "apply immediate on blockDeviceRefs add disk", + "no changes on blockDeviceRefs add disk with paravirt enabled", ` enableParavirtualization: true blockDeviceRefs: @@ -297,13 +297,10 @@ blockDeviceRefs: name: linux `, nil, - assertChanges( - actionRequired(ActionApplyImmediate), - requirePathOperation("blockDeviceRefs.0", ChangeAdd), - ), + assertNoChanges(), }, { - "apply immediate on blockDeviceRefs remove disk", + "no changes on blockDeviceRefs remove disk with paravirt enabled", ` enableParavirtualization: true blockDeviceRefs: @@ -319,10 +316,7 @@ blockDeviceRefs: name: linux `, nil, - assertChanges( - actionRequired(ActionApplyImmediate), - requirePathOperation("blockDeviceRefs.0", ChangeRemove), - ), + assertNoChanges(), }, { "restart on blockDeviceRefs remove disk with paravirt disabled", @@ -347,7 +341,7 @@ blockDeviceRefs: ), }, { - "apply immediate on blockDeviceRefs change order", + "no changes on blockDeviceRefs change order with paravirt enabled", ` enableParavirtualization: true blockDeviceRefs: @@ -365,14 +359,10 @@ blockDeviceRefs: name: linux `, nil, - assertChanges( - actionRequired(ActionApplyImmediate), - requirePathOperation("blockDeviceRefs.0", ChangeReplace), - requirePathOperation("blockDeviceRefs.1", ChangeReplace), - ), + assertNoChanges(), }, { - "apply immediate on blockDeviceRefs change order :: bigger", + "no changes on blockDeviceRefs change order with paravirt enabled :: bigger", ` enableParavirtualization: true blockDeviceRefs: @@ -403,12 +393,7 @@ blockDeviceRefs: name: linux `, nil, - assertChanges( - actionRequired(ActionApplyImmediate), - requirePathOperation("blockDeviceRefs.0", ChangeReplace), - requirePathOperation("blockDeviceRefs.1", ChangeReplace), - requirePathOperation("blockDeviceRefs.4", ChangeReplace), - ), + assertNoChanges(), }, { "restart on provisioning add", @@ -769,6 +754,13 @@ func assertChanges(asserts ...func(t *testing.T, changes SpecChanges)) func(t *t } } +func assertNoChanges() func(t *testing.T, changes SpecChanges) { + return func(t *testing.T, changes SpecChanges) { + t.Helper() + require.True(t, changes.IsEmpty(), "changes should be empty, got %+v", changes) + } +} + func actionRequired(actionType ActionType) func(t *testing.T, changes SpecChanges) { return func(t *testing.T, changes SpecChanges) { t.Helper()