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

Backports of 81db7e6 and bc7f240 #879

Merged
merged 2 commits into from
May 2, 2024
Merged
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
8 changes: 6 additions & 2 deletions pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,12 @@ func (r *KubeVirt) dataVolumes(vm *plan.VMStatus, secret *core.Secret, configMap
annotations[AnnDefaultNetwork] = path.Join(
r.Plan.Spec.TransferNetwork.Namespace, r.Plan.Spec.TransferNetwork.Name)
}
// Set annotation for WFFC storage classes
annotations[planbase.AnnBindImmediate] = "true"
if r.Plan.Spec.Warm || !r.Destination.Provider.IsHost() || r.Plan.IsSourceProviderOCP() {
// Set annotation for WFFC storage classes. Note that we create data volumes while
// running a cold migration to the local cluster only when the source is either OpenShift
// or vSphere, and in the latter case the conversion pod acts as the first-consumer
annotations[planbase.AnnBindImmediate] = "true"
}
// Do not delete the DV when the import completes as we check the DV to get the current
// disk transfer status.
annotations[AnnDeleteAfterCompletion] = "false"
Expand Down
26 changes: 16 additions & 10 deletions pkg/controller/provider/container/vsphere/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,44 +688,50 @@ func (v *VmAdapter) updateDisks(devArray *types.ArrayOfVirtualDevice) {
switch disk.Backing.(type) {
case *types.VirtualDiskFlatVer1BackingInfo:
backing := disk.Backing.(*types.VirtualDiskFlatVer1BackingInfo)
datastoreId, _ := sanitize(backing.Datastore.Value)
md := model.Disk{
Key: disk.Key,
File: backing.FileName,
Capacity: disk.CapacityInBytes,
Datastore: model.Ref{
}
if backing.Datastore != nil {
datastoreId, _ := sanitize(backing.Datastore.Value)
md.Datastore = model.Ref{
Kind: model.DsKind,
ID: datastoreId,
},
}
}
disks = append(disks, md)
case *types.VirtualDiskFlatVer2BackingInfo:
backing := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
datastoreId, _ := sanitize(backing.Datastore.Value)
md := model.Disk{
Key: disk.Key,
File: backing.FileName,
Capacity: disk.CapacityInBytes,
Shared: backing.Sharing != "sharingNone",
Datastore: model.Ref{
}
if backing.Datastore != nil {
datastoreId, _ := sanitize(backing.Datastore.Value)
md.Datastore = model.Ref{
Kind: model.DsKind,
ID: datastoreId,
},
}
}
disks = append(disks, md)
case *types.VirtualDiskRawDiskMappingVer1BackingInfo:
backing := disk.Backing.(*types.VirtualDiskRawDiskMappingVer1BackingInfo)
datastoreId, _ := sanitize(backing.Datastore.Value)
md := model.Disk{
Key: disk.Key,
File: backing.FileName,
Capacity: disk.CapacityInBytes,
Shared: backing.Sharing != "sharingNone",
Datastore: model.Ref{
RDM: true,
}
if backing.Datastore != nil {
datastoreId, _ := sanitize(backing.Datastore.Value)
md.Datastore = model.Ref{
Kind: model.DsKind,
ID: datastoreId,
},
RDM: true,
}
}
disks = append(disks, md)
case *types.VirtualDiskRawDiskVer2BackingInfo:
Expand Down
15 changes: 15 additions & 0 deletions validation/policies/io/konveyor/forklift/vmware/datastore.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.konveyor.forklift.vmware

null_datastore {
some i
count(input.disks[i].datastore.id) == 0
}

concerns[flag] {
null_datastore
flag := {
"category": "Critical",
"label": "Disk is not located on a datastore",
"assessment": "The VM is configured with a disk that is not located on a datastore. The VM cannot be migrated"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.konveyor.forklift.vmware

test_with_no_disks {
mock_vm := {
"name": "test",
"disks": []
}
results := concerns with input as mock_vm
count(results) == 0
}

test_with_valid_disk {
mock_vm := {
"name": "test",
"disks": [
{ "datastore": { "kind": "datastore", "id": "datastore-1" } }
]
}
results := concerns with input as mock_vm
count(results) == 0
}

test_with_invalid_disk {
mock_vm := {
"name": "test",
"disks": [
{ "datastore": { "kind": "datastore", "id": "datastore-1" } },
{ "datastore": { "kind": "", "id": "" } },
]
}
results := concerns with input as mock_vm
count(results) == 1
}
Loading