Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ blockDeviceRefs:
),
},
{
"apply immediate on blockDeviceRefs add disk",
"no changes on blockDeviceRefs add disk with paravirt enabled",
`
enableParavirtualization: true
blockDeviceRefs:
Expand All @@ -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:
Expand All @@ -319,10 +316,7 @@ blockDeviceRefs:
name: linux
`,
nil,
assertChanges(
actionRequired(ActionApplyImmediate),
requirePathOperation("blockDeviceRefs.0", ChangeRemove),
),
assertNoChanges(),
},
{
"restart on blockDeviceRefs remove disk with paravirt disabled",
Expand All @@ -347,7 +341,7 @@ blockDeviceRefs:
),
},
{
"apply immediate on blockDeviceRefs change order",
"no changes on blockDeviceRefs change order with paravirt enabled",
`
enableParavirtualization: true
blockDeviceRefs:
Expand All @@ -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:
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down
Loading