Bug 1990560

Summary: [2.6.z] Disk is not usable due to incorrect size for proper alignment
Product: Container Native Virtualization (CNV) Reporter: Adam Litke <alitke>
Component: StorageAssignee: Alexander Wels <awels>
Status: CLOSED ERRATA QA Contact: Kevin Alon Goldblatt <kgoldbla>
Severity: high Docs Contact:
Priority: unspecified    
Version: 2.6.5CC: awels, cnv-qe-bugs, gveitmic, kgershon, kgoldbla, mrashish, nrevo, tmicheli, yadu
Target Milestone: ---   
Target Release: 2.6.7   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-cdi-operator:v2.6.6-6, CNV v2.6.7-8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1976730 Environment:
Last Closed: 2021-10-05 17:35:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1976730    
Bug Blocks: 1990559    

Comment 2 Kevin Alon Goldblatt 2021-08-23 12:12:59 UTC
Verified with the following code:
---------------------------------------------
oc version
Client Version: 4.8.0-202103311007.p0-be64dc7
Server Version: 4.7.20
Kubernetes Version: v1.20.0+bd7b30d

oc get csv -n openshift-cnv
NAME                                      DISPLAY                    VERSION   REPLACES                                  PHASE
kubevirt-hyperconverged-operator.v2.6.7   OpenShift Virtualization   2.6.7     kubevirt-hyperconverged-operator.v2.6.6   Succeeded



Verified with the following scenario:
---------------------------------------------
1. Connect to a host on the cluster:
oc debug node/stg10-kevin-jdtkw-worker-0-7f69w

sh-4.4# chroot /host/

2. Prepare 4K aligned fake block storage
fallocate -l 10GiB /var/iscsi
losetup -f -b 4096 /var/iscsi 
losetup -l 
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                                        DIO LOG-SEC
/dev/loop1
             0      0         0  0 /var/iscsi                                         0    4096

3. Install the filesystem and mount the device:
mkfs.ext4 -b 4096 /var/iscsi
mkdir  /var/hpvolumes/4k  
mount /dev/loop1 /var/hpvolumes/4k/  

4. Label the device:
ls -ltrZ /var/hpvolumes/4k
total 16
drwx------. 2 root root system_u:object_r:unlabeled_t:s0 16384 Aug 19 15:30 lost+found
sudo chcon -t container_file_t -R /var/hpvolumes/4k
ls -ltrZ /var/hpvolumes/4k
total 16
drwx------. 2 root root system_u:object_r:container_file_t:s0 16384 Aug 19 15:30 lost+found

5. Create a special pv pointing to the loopback device created: (see yaml below)

6. Create a storageclass on the new PV (see yaml below)

7. Create the vm using the new storageclass: (see yaml below)
oc create -f cirros-vm.yaml 
virtualmachine.kubevirt.io/vm-cirros-dv-2 created

8. oc get dv -w
NAME          PHASE       PROGRESS   RESTARTS   AGE
cirros-dv-2   Succeeded   100.0%                9s

9. Start vm:
oc get vm
NAME             AGE   STATUS    READY
vm-cirros-dv-2   28s   Stopped   False
virtctl start vm-cirros-dv-2
VM vm-cirros-dv-2 was scheduled to start
oc get vmi
NAME             AGE   PHASE     IP             NODENAME                           READY
vm-cirros-dv-2   17s   Running   10.128.2.178   stg10-kevin-jdtkw-worker-0-7f69w   True
[cnv-qe-jenkins@stg10-kevin-jdtkw-executor kev]$ virtctl console vm-cirros-dv-2
Successfully connected to vm-cirros-dv-2 console. The escape sequence is ^]

>>>>> VMI is running and vm can be accessed


Moving to verified!



Additional information:
---------------------------------------------------------------------------------
special pv yaml:
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-pv-volume
  labels:
    type: local
spec:
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - stg10-kevin-jdtkw-worker-0-7f69w
  storageClassName: test-sc
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/var/hpvolumes/4k"




StorageClass yaml:
cat sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: test-sc
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Delete
volumeBindingMode: Immediate




vm yaml:
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  labels:
    kubevirt.io/vm: vm-cirros-dv-2
  name: vm-cirros-dv-2
spec:
  dataVolumeTemplates:
  - metadata:
      name: cirros-dv-2
    spec:
      pvc:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 100M
        storageClassName: test-sc
      source:
        http:
          url: "http://xxx/xxx/xxx/cirros-0.4.0-x86_64-disk.qcow2"
  running: false
  template:
    metadata:
      labels:
        kubevirt.io/vm: vm-datavolume
    spec:
      domain:
        devices:
          disks:
          - disk:
              bus: virtio
            name: datavolumevolume
        machine:
          type: ""
        resources:
          requests:
            memory: 64M
      terminationGracePeriodSeconds: 0
      volumes:
      - dataVolume:
          name: cirros-dv-2
        name: datavolumevolume

Comment 8 errata-xmlrpc 2021-10-05 17:35:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Low: OpenShift Virtualization 2.6.7 Images security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:3733