Bug 2252210

Summary: Cross storage class cloning from DataSource is selecting incorrect volumeMode
Product: Container Native Virtualization (CNV) Reporter: nijin ashok <nashok>
Component: StorageAssignee: Adam Litke <alitke>
Status: CLOSED MIGRATED QA Contact: Natalie Gavrielov <ngavrilo>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.14.0CC: gveitmic
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-12-14 16:04:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nijin ashok 2023-11-30 06:26:48 UTC
Description of problem:

Got datasource PVC in `ocs-external-storagecluster-ceph-rbd` storage class with volumeMode block. Tried to create a new VM from the template to another storage class nfs-csi. The created temporary source PVC has got `volumeMode: filesystem` instead of block.

~~~
# oc get pvc tmp-source-pvc-b32507e1-8fc4-4143-96a4-c01235f03a12  -n openshift-virtualization-os-images  -o json |jq '.spec'
{
  "accessModes": [
    "ReadWriteMany"
  ],
  "dataSource": {
    "apiGroup": "snapshot.storage.k8s.io",
    "kind": "VolumeSnapshot",
    "name": "rhel8-3d8ef774e232"
  },
  "dataSourceRef": {
    "apiGroup": "snapshot.storage.k8s.io",
    "kind": "VolumeSnapshot",
    "name": "rhel8-3d8ef774e232"
  },
  "resources": {
    "requests": {
      "storage": "30Gi"
    }
  },
  "storageClassName": "ocs-external-storagecluster-ceph-rbd",
  "volumeMode": "Filesystem"                                     <=====
}

# oc get VolumeSnapshot rhel8-3d8ef774e232 -n openshift-virtualization-os-images -o json |yq '.spec,.status'

{"source": {"persistentVolumeClaimName": "rhel8-3d8ef774e232"}, "volumeSnapshotClassName": "ocs-external-storagecluster-rbdplugin-snapclass"}
{"boundVolumeSnapshotContentName": "snapcontent-511b5e9a-0918-4037-83e5-cb9cabfcb5c2", "creationTime": "2023-11-15T14:50:57Z", "readyToUse": true, "restoreSize": "30Gi"}

~~~  

So the provisioning fails at the ceph CSI end:

~~~
I1130 05:01:41.030965       1 event.go:298] Event(v1.ObjectReference{Kind:"PersistentVolumeClaim", Namespace:"openshift-virtualization-os-images", Name:"tmp-source-pvc-b32507e1-8fc4-4143-96a4-c01235f03a12", UID:"cc9bebb3-efcb-46ab-8c10-8d79bbaccb0d", APIVersion:"v1", ResourceVersion:"34875794", FieldPath:""}): type: 'Warning' reason: 'ProvisioningFailed' failed to provision volume with StorageClass "ocs-external-storagecluster-ceph-rbd": rpc error: code = InvalidArgument desc = multi node access modes are only supported on rbd `block` type volumes
~~~

It looks like it's copying the volumemode and accessmode from the target PVC which will not be always correct [1].

~~~
# oc get pvc rhel8-mean-asp -n nijin-cnv -o json |jq '.spec'
{
  "accessModes": [
    "ReadWriteMany"
  ],
  "dataSource": {
    "apiGroup": "cdi.kubevirt.io",
    "kind": "VolumeCloneSource",
    "name": "volume-clone-source-8b84f0bb-5a3f-4ae8-aaca-67ceb956401f"
  },
  "dataSourceRef": {
    "apiGroup": "cdi.kubevirt.io",
    "kind": "VolumeCloneSource",
    "name": "volume-clone-source-8b84f0bb-5a3f-4ae8-aaca-67ceb956401f"
  },
  "resources": {
    "requests": {
      "storage": "34087042032"
    }
  },
  "storageClassName": "nfs-csi",
  "volumeMode": "Filesystem"        <===
}
~~~
 


Version-Release number of selected component (if applicable):

OpenShift Virtualization   4.14.0

How reproducible:

100%

Steps to Reproduce:

1. Populate the template boot source images in ceph rbd storage class.
2. Create a new VM from a template and change the disk to another filesystem storage class.

Create => From template => select template => Customize Virtual machine parameters => Disks => Change the disk storage class.

3. VM will be stuck in provisioning status for ever.

Actual results:

Cross storage class cloning from DataSource in selecting incorrect volumeMode 

Expected results:

It should select the correct volumeMode from source PVC.

Additional info:

[1] https://github.com/kubevirt/containerized-data-importer/blob/319a27faade112e6f20cf1cdd0d528e5727b0959/pkg/controller/clone/planner.go#L776