Skip to content
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

Handle lost sparseness in non http data sources #3213

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

akalenyu
Copy link
Collaborator

@akalenyu akalenyu commented Apr 21, 2024

What this PR does / why we need it:
Handle some non-http sources where we lose sparseness similarly to #3219

For this to be complete, we must fix the broken check for sparseness in e2e, to help us test against regression.
The first issue is that we look at content size since #2168,
which is not beneficial in the sparseness check as opposed to disk usage.

The second issue is that the check we have in tests for sparseness is not honest because of the "equal to" part.
The virtual size has to be strictly greater than the size on disk.

The third issue is that we almost always resize which results in significantly larger virtual size.
What we really care about is comparing against the original virtual size of the image.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

NONE

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/M labels Apr 21, 2024
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from akalenyu. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@akalenyu akalenyu force-pushed the sparse-check-tests branch 2 times, most recently from db6ec2c to 3dc043f Compare April 21, 2024 21:53
@akalenyu akalenyu changed the title [WIP] Correct wrong check of resulting image sparsiness Correct wrong check of resulting image sparseness Apr 21, 2024
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 21, 2024
@akalenyu akalenyu force-pushed the sparse-check-tests branch 5 times, most recently from c2a3372 to e9c286a Compare April 21, 2024 23:47
@akalenyu
Copy link
Collaborator Author

/test all

@akalenyu akalenyu force-pushed the sparse-check-tests branch 2 times, most recently from 2fddf72 to c4388c6 Compare April 30, 2024 12:54
@akalenyu
Copy link
Collaborator Author

/retest

@akalenyu akalenyu force-pushed the sparse-check-tests branch 2 times, most recently from 4c77744 to 86ef1bf Compare May 1, 2024 10:24
@akalenyu akalenyu changed the title Correct wrong check of resulting image sparseness Handle lost sparseness in non http data sources May 1, 2024
@akalenyu
Copy link
Collaborator Author

akalenyu commented May 1, 2024

/test pull-containerized-data-importer-fossa

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2024
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 29, 2024
@coveralls
Copy link

coveralls commented Jul 29, 2024

Coverage Status

coverage: 59.141% (-0.03%) from 59.168%
when pulling 483318c on akalenyu:sparse-check-tests
into e263c02 on kubevirt:main.

Copy link
Collaborator

@alromeros alromeros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice, just a couple of comments

return info.VirtualSize >= imageContentSize, nil
fmt.Fprintf(ginkgo.GinkgoWriter, "INFO: VerifySparse comparison: OriginalVirtual: %d vs SizeOnDisk: %d\n", originalVirtualSize, info.ActualSize)
// The size on disk of a sparse image is significantly lower than the image's virtual size
return originalVirtualSize-info.ActualSize >= units.MB, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably intentional but why use units.MB instead of the previously used MiB ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah intentional but it's been a while so I don't remember the exact reasoning, have to take a look

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the 1MB fudge factor all about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its probably to ensure we align the size on 1Mib. qemu gets unhappy if the image is not aligned on the actual storage block size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check is a little too strict, wondering why current virtual size is not appropriate

Copy link
Collaborator Author

@akalenyu akalenyu Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I looked up the 1MiB->1MB switch.
It's because qemu-img convert only manages to shave off one megabyte (not mebi) for our test image
INFO: VerifySparse comparison: OriginalVirtual: 18874368 vs SizeOnDisk: 17829888

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this check is specific to a particular image?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you pass the virtual size of the used image as a parameter

@@ -51,8 +54,7 @@ func (ud *UploadDataSource) Info() (ProcessingPhase, error) {
if ud.contentType == cdiv1.DataVolumeArchive {
return ProcessingPhaseTransferDataDir, nil
}
if !ud.readers.Convert {
// Uploading a raw file, we can write that directly to the target.
if ud.directWriteException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pass the source content type and do the sourceContentType == common.BlockdeviceClone here? It makes this easier to debug and understand than having an arbitrary directWriteException that's not too informative. Just a nit though, feel free to ignore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be a little awkward having it know about source content type

@akalenyu
Copy link
Collaborator Author

/hold

@kubevirt-bot kubevirt-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2024
@@ -284,24 +283,15 @@ func (f *Framework) VerifyBlankDisk(namespace *k8sv1.Namespace, pvc *k8sv1.Persi
}

// VerifySparse checks a disk image being sparse after creation/resize.
func (f *Framework) VerifySparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, imagePath string) (bool, error) {
func (f *Framework) VerifySparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, imagePath string, originalVirtualSize int64) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not get rid of this function and check !VerifyImagePreallocated()?

Copy link
Collaborator Author

@akalenyu akalenyu Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly because of the third point in the PR description

The third issue is that we almost always resize which results in significantly larger virtual size.
What we really care about is comparing against the original virtual size of the image.

We could get rid of one of them by negating the other but those additions have to stay

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we really care about is comparing against the original virtual size of the image.

Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since current virtual size is post-resize you always end up comparing 1Gi or more (requested disk image size) versus a modest couple of megabytes, which is always going to pass as sort of a false negative

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 16, 2024
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 19, 2024
The first issue is that we look at content size since 2168,
which is not beneficial in the sparseness check as opposed to disk usage.

The second issue is that the check we have in tests for sparsiness is not honest because of the "equal to" part.
The virtual size has to be strictly greater than the content
(as the content is displayed by tools that understand sparseness).

The third issue is that we almost always resize which results in significantly larger virtual size.
What we really care about is comparing against the original virtual size of the image.

Signed-off-by: Alex Kalenyuk <[email protected]>
Basically a follow up to 3219 for upload sources,
which suffer from the same issue of losing sparseness.

Signed-off-by: Alex Kalenyuk <[email protected]>
- ImageIO raw images are not passed through any sparsification mechanism
- VDDK ones do, but the fake plugin used for testing lies that they're
  not

Signed-off-by: Alex Kalenyuk <[email protected]>
@akalenyu
Copy link
Collaborator Author

akalenyu commented Sep 1, 2024

/retest

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Sep 1, 2024

@akalenyu: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-containerized-data-importer-e2e-ceph 483318c link true /test pull-containerized-data-importer-e2e-ceph

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-signoff: yes Indicates the PR's author has DCO signed all their commits. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants