Bug 2001041

Summary: [4.9.0] Importer attempts to shrink an image in certain situations
Product: Container Native Virtualization (CNV) Reporter: Adam Litke <alitke>
Component: StorageAssignee: Alexander Wels <awels>
Status: CLOSED ERRATA QA Contact: Jenia Peimer <jpeimer>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.9.0CC: awels, brybacki, cnv-qe-bugs, ycui
Target Milestone: ---   
Target Release: 4.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: v4.9.0-194 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2001038 Environment:
Last Closed: 2021-11-02 16:01:09 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: 2001038    
Bug Blocks:    

Description Adam Litke 2021-09-03 15:42:32 UTC
+++ This bug was initially created as a clone of Bug #2001038 +++

Description of problem: Due to an off by one rounding error, we may determine that there is not enough space to contain a disk image in a PVC with filesystem overhead.  Additionally, we may call 'qemu-img resize' with a smaller value than the current image size.


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


How reproducible: Always


Steps to Reproduce:
1. Create a DV with a size that is barely too small to fit its source disk image

Actual results:
the following appears in the importer logs:
E0901 16:10:54.345673       1 prlimit.go:176] qemu-img: Use the --shrink option to perform a shrink operation.
qemu-img: warning: Shrinking an image will delete all data beyond the shrunken image's end. Before performing such an operation, make sure there is no important data there.

Expected results:
A clearer message indicating that the PVC is not big enough for this image should be printed.


Additional info:

We need to enhance CDI's validation and resize logic in the following two ways:
1. When calculating available space in a PVC, round up to the next integer and then align down to the nearest MB.
2. Before calling qemu-img resize, validate that the target size is >= the current image virtualsize.

Comment 4 errata-xmlrpc 2021-11-02 16:01:09 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 (Moderate: OpenShift Virtualization 4.9.0 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:4104