Bug 2189455 - [4.10]preallocation is always applied when importing image to block storage
Summary: [4.10]preallocation is always applied when importing image to block storage
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Storage
Version: 4.10.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: 4.10.9
Assignee: Álvaro Romero
QA Contact: Yan Du
URL:
Whiteboard:
Depends On: 2168165 2189460 2189463
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-25 10:13 UTC by Álvaro Romero
Modified: 2023-06-16 10:28 UTC (History)
6 users (show)

Fixed In Version: v4.10.9-18
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2168165
Environment:
Last Closed: 2023-06-13 15:37:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github kubevirt containerized-data-importer pull 2657 0 None Merged [release-v1.43] Stop forcing preallocation on block imports 2023-04-25 10:13:01 UTC
Red Hat Issue Tracker CNV-28355 0 None None None 2023-04-25 10:16:31 UTC
Red Hat Product Errata RHEA-2023:3574 0 None None None 2023-06-13 15:38:02 UTC

Description Álvaro Romero 2023-04-25 10:13:02 UTC
+++ This bug was initially created as a clone of Bug #2168165 +++

Description of problem:

When we create a datavolume by importing an image via http url, preallocation is being applied .We tried setting preallocation to false, but still preallocation is being applied.

storage class name : ocs-external-storagecluster-ceph-rbd

Version-Release number of selected component (if applicable):
Server Version: 4.12.1
OpenShift Virtualization   4.12.0

How reproducible:
100%

Steps to Reproduce:

1.Used below image to create our volume, actual size of this image is 747MB

#qemu-img info rhel-8.5-update-2-x86_64-kvm.qcow2
image: rhel-8.5-update-2-x86_64-kvm.qcow2
file format: qcow2
virtual size: 10 GiB (10737418240 bytes)
disk size: 747 MiB
cluster_size: 65536
Format specific information:
    compat: 0.10
    refcount bits: 16


2. Created datavol.yaml with preallocation: false 

  # cat datavol.yaml 
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
  name: preallocation-false2
spec:
  preallocation: false
  storage:
    resources:
      requests:
        storage: 20Gi
    storageClassName: ocs-external-storagecluster-ceph-rbd
    volumeMode: Block
  source:
    http:
       url: http://10.74.128.145/rhel-8.5-update-2-x86_64-kvm.qcow2


2. Created a dv from the above yaml file

# oc apply -f datavol.yaml 
datavolume.cdi.kubevirt.io/preallocation-false2 created


#oc logs -f importer-preallocation-false2
I0208 10:06:15.478140       1 importer.go:104] Starting importer
I0208 10:06:15.479217       1 importer.go:171] begin import process
I0208 10:06:15.481932       1 data-processor.go:379] Calculating available size
I0208 10:06:15.483183       1 data-processor.go:387] Checking out block volume size.
I0208 10:06:15.483201       1 data-processor.go:399] Request image size not empty.
I0208 10:06:15.483210       1 data-processor.go:404] Target size 21474836480.
I0208 10:06:15.483618       1 nbdkit.go:303] Waiting for nbdkit PID.
I0208 10:06:15.990529       1 nbdkit.go:324] nbdkit ready.
I0208 10:06:15.990584       1 data-processor.go:282] New phase: Convert
I0208 10:06:15.990597       1 data-processor.go:288] Validating image
I0208 10:06:16.165295       1 qemu.go:332] Adding preallocation method: [-o preallocation=falloc]
I0208 10:06:16.170468       1 qemu.go:259] 0.00

The used size of the image is equal to the virtual size of the image.

# rbd du csi-vol-35cc672d-a798-11ed-8a89-0a580a80001a
NAME                                          PROVISIONED  USED  
csi-vol-35cc672d-a798-11ed-8a89-0a580a80001a       20 GiB  10 GiB


Actual results: 

On checking the pod logs for the created volume, we could see that preallocation is being applied and it consumed 10GB from the CEPH end (logs provided in the above step) 



Expected results: 
Since we applied preallocation to false in the datavol.yaml file , the created volume size should consume only 747MiB which is actually the disk size of the img we are using.

--- Additional comment from nijin ashok on 2023-02-10 14:56:59 UTC ---

The preallocation was enabled always in the block as per [1] (to fix [2] but don't have much info about the root cause).

I tried reproducing the issue with the ubuntu image mentioned in the above issue (after converting to RAW) by using a ceph rbd volume mapped via krbd. I was not able to reproduce the issue with the same "qemu-img convert" options. Not sure if this was because of some bug in qemu-img which was already fixed.

Also, refer to https://github.com/kubevirt/containerized-data-importer/issues/2160.

  
[1] https://github.com/kubevirt/containerized-data-importer/pull/2001
[2] https://github.com/kubevirt/containerized-data-importer/issues/1980

Comment 2 Ivan 2023-06-01 11:03:49 UTC
Hello @yadu,

Do we have any news? 
The partner would like to know what is the current status of the backporting.

Thanks a lot in advance,

Ivan G.
Partner Technical Account Maanger

Comment 3 Yan Du 2023-06-02 09:58:07 UTC
Test on CNV-v4.10.9-52, issue has been fixed.

$ qemu-img info rhel-85.raw
image: rhel-85.raw
file format: raw
virtual size: 10 GiB (10737418240 bytes)
disk size: 1.68 GiB


sh-4.4$ rbd du ocs-storagecluster-cephblockpool/csi-vol-6c06b1d2-012a-11ee-9e3b-0a580a830020
NAME                                          PROVISIONED  USED   
csi-vol-6c06b1d2-012a-11ee-9e3b-0a580a830020       20 GiB  1.7 GiB

Comment 9 errata-xmlrpc 2023-06-13 15:37:58 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 (OpenShift Virtualization 4.10.9 Images), 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/RHEA-2023:3574


Note You need to log in before you can comment on or make changes to this bug.