-
Notifications
You must be signed in to change notification settings - Fork 779
fix: Remove premature return after closing sparse diff file so Convert executes. #4421
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
base: master
Are you sure you want to change the base?
Conversation
…t executes. Ensure diffDisk is converted to the requested format instead of staying sparse. Signed-off-by: ashwat287 <[email protected]>
| return fmt.Errorf("failed to create sparse diff disk %q: %w", diffDisk, err) | ||
| } | ||
| return diffDiskF.Close() | ||
| diffDiskF.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you test this PR?
The diffDisk created in L43 will be overwritten by a new disk converted from baseDisk in L57, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes diffDisk would get converted in L57 when the base image is ISO.
I have include the tests to verify the conditions when base image is ISO and non-ISO
Can you please clarify on what should be the desired behaviors in each test cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the base disk is an ISO9660 image, the diff disk has to be a new empty disk.
("diff" is misnomer here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff disk when created as a sparse file in L49 is empty and has size 0 bytes.
On debugging, I find that after conversion the diffdisk size becomes equal to diskSizeInBytes.
To keep the diffDisk empty we can either:
- not convert the
diffDiskand leave it as a sparse file and eventually ignorediskImageFormatwhen the base disk is ISO. or, - convert the
diffDiskto the available formats while keepingdiskSizeInBytes=0in case of ISO base disk. The problem here arises when the disk is being converted toasifformat, the following error gets thrownspecified size 0 is smaller than the original image sizebecause oflima/pkg/imgutil/nativeimgutil/nativeimgutil.go
Lines 59 to 61 in 9dbf572
if size != nil && *size < srcImg.Size() { return fmt.Errorf("specified size %d is smaller than the original image size (%d) of %q", *size, srcImg.Size(), source) }
Add pkg/driverutil/disk_test.go covering: - Base image is ISO: EnsureDisk creates/keeps diffdisk and converts to raw; base ISO remains unchanged (content hash and ISO signature). - Base image is non-ISO: EnsureDisk converts diffdisk to raw. Signed-off-by: ashwat287 <[email protected]>
Fixes #4418
Ensure diffDisk is converted to the requested format instead of staying sparse.