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

Specify image size #522

Merged
merged 2 commits into from
Nov 20, 2018
Merged

Specify image size #522

merged 2 commits into from
Nov 20, 2018

Conversation

awels
Copy link
Member

@awels awels commented Nov 14, 2018

Combined code from #489 and #490 by
@gites and
@danielerez
Added some tests and rebased on current master.

What this PR does / why we need it:
This PR calculates the needed image size based on the PVC request size (Not the actual PVC size), and resizes the image to match.

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 #482

Special notes for your reviewer:
This should finally get the feature in CDI.

Release note:

Disk images are resized to the PVC request size.

Co-authored-by: Tomasz Pawelczak [email protected]
Co-authored-by: Daniel Erez [email protected]

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L labels Nov 14, 2018
@awels
Copy link
Member Author

awels commented Nov 14, 2018

ci test please

@awels awels force-pushed the specify_image_size branch from 7cb7922 to 64da5a0 Compare November 14, 2018 20:58
@awels
Copy link
Member Author

awels commented Nov 15, 2018

ci test please

1 similar comment
@awels
Copy link
Member Author

awels commented Nov 15, 2018

ci test please

@awels
Copy link
Member Author

awels commented Nov 16, 2018

/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 Nov 16, 2018
@awels awels force-pushed the specify_image_size branch from cf5af2a to 588116b Compare November 16, 2018 16:44
@awels
Copy link
Member Author

awels commented Nov 19, 2018

ci test please

@awels awels force-pushed the specify_image_size branch from 588116b to 035349e Compare November 19, 2018 18:05
@j-griffith
Copy link
Contributor

LGTM other than updating the comment to reflect the current direction on this... will merge after that's updated and CI passes.

@awels
Copy link
Member Author

awels commented Nov 19, 2018

/hold cancel

@kubevirt-bot kubevirt-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 19, 2018
@awels awels force-pushed the specify_image_size branch from 592c26e to 809135e Compare November 19, 2018 20:40
@awels awels force-pushed the specify_image_size branch from 809135e to 6c6331a Compare November 20, 2018 16:18
@awels awels force-pushed the specify_image_size branch from cad870d to 10a2fc0 Compare November 20, 2018 19:26
pkg/importer/dataStream.go Outdated Show resolved Hide resolved
pkg/importer/dataStream.go Outdated Show resolved Hide resolved
Combined code from PR#489 and PR#490 by
@gites and
@danielerez
Added some tests and rebased on current master.

Signed-off-by: Alexander Wels <[email protected]>
@awels awels force-pushed the specify_image_size branch from 10a2fc0 to 260d4fa Compare November 20, 2018 20:40
@awels awels merged commit 546fdb4 into kubevirt:master Nov 20, 2018
@awels awels mentioned this pull request Nov 20, 2018
// ResizeImage resizes the images to match the requested size. Sometimes provisioners misbehave and the available space
// is not the same as the requested space. For those situations we compare the available space to the requested space and
// use the smallest of the two values.
func ResizeImage(dest, imageSize string) error {
Copy link
Contributor

@zvikorn zvikorn Nov 21, 2018

Choose a reason for hiding this comment

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

@awels Is this being called somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, you are right it is not, but obviously it should, making a patch to fix now.

@zvikorn
Copy link
Contributor

zvikorn commented Nov 21, 2018

@awels where do we do the filesystem overhead calculation and subtract from requested size?

@awels
Copy link
Member Author

awels commented Nov 21, 2018

@zvikorn ResizeImage does the calculation. The algorithm is: take whatever is passed from the controller (The request size) and then compare to the available space on the file system of the PVC that is mounted in the container. Pick the lesser of the two.

@zvikorn
Copy link
Contributor

zvikorn commented Nov 21, 2018

@awels As I need to use this algo as well, should we remove this from datastream over to util and make it common?

@awels
Copy link
Member Author

awels commented Nov 21, 2018 via email

@zvikorn
Copy link
Contributor

zvikorn commented Nov 21, 2018 via email

@zvikorn
Copy link
Contributor

zvikorn commented Nov 22, 2018

@awels so.... I cannot use the GetAvailableSpace as the PVC is not bound yet at that point. I will subtract 4% for FS from the requested image size, unless we have something else to think about...

@awels
Copy link
Member Author

awels commented Nov 22, 2018

Not sure what you mean, in the importer the PVC is by definition bound, and that is where you have to do the calculation of which one to pick.

@zvikorn
Copy link
Contributor

zvikorn commented Nov 23, 2018

yea, I take my words back. I believe the PVC is bound at that point.
Anyway, I do not understand the connection between the GetAvailableSpace result and the FS overhead we need to take into account. Could you please elaborate about this a bit?
By the way, GetAvailableSpace returns '0' for me. Did it worked for you in the Resize patch? Did you verify the image size after resize is not '0'?

@awels
Copy link
Member Author

awels commented Nov 23, 2018

So we don't have to take the FS overhead into account anymore, since its mounted with a FS on it, the available reported by the FS is what is available. We are just taking the minimum of that that value and the requested image size.

@awels
Copy link
Member Author

awels commented Nov 23, 2018

Also just verified that I am getting the requested information from GetAvailableSpace, however found a bug that its not actually calling resize image at the right time, will have a PR to fix that soon.

@zvikorn
Copy link
Contributor

zvikorn commented Nov 23, 2018 via email

@zakkg3
Copy link

zakkg3 commented Oct 1, 2020

Also just verified that I am getting the requested information from GetAvailableSpace, however found a bug that its not actually calling resize image at the right time, will have a PR to fix that soon.

Is this fixed ?
i have a dataVolumeTemplates requesting 250Gi. the pvc is created with this size. then it clones the disk from a source pvc in another namespace (10G) but it never resizes the image. so my vm sees 10Gb instead of the 250...
Iam running cdi v1.19.0

@awels
Copy link
Member Author

awels commented Oct 1, 2020

So this particular issue is talking about the virtual disk size. We do NOT resize the partition inside the VM because we don't know which (if there are multiple) partition you would like to have resized. So if you run something like fdisk inside the VM, it will show the disk is the size you requested, however the partitions will not be.

@zakkg3
Copy link

zakkg3 commented Oct 1, 2020

Hi, thanks for the fast answer. I ve read your comment #1150 (comment) so i did but:

[root@vm-disk-big ~]# fdisk -l

Disk /dev/vda: 10.7 GB, 10737090560 bytes, 20970880 sectors
k get pvc 
vm-disk-big-disk        Bound    pvc-38b6ca99-d898-4bd9-8b96-5ffb6858a8d0   250Gi      RWX            netapp         123m

It seems its not resizing the virtual disk size..

k logs cdi-upload-vm-disk-big-disk -f
I1001 12:56:26.729816       1 uploadserver.go:63] Upload destination: /data/disk.img
I1001 12:56:26.729924       1 uploadserver.go:65] Running server on 0.0.0.0:8443
I1001 12:56:40.596917       1 uploadserver.go:319] Content type header is "filesystem-clone"
I1001 12:57:11.687584       1 util.go:174] begin untar to /data...
I1001 13:00:17.441136       1 uploadserver.go:338] Wrote data to /data/disk.img
I1001 13:00:17.441289       1 uploadserver.go:155] Shutting down http server after successful upload
I1001 13:00:17.942003       1 uploadserver.go:89] UploadServer successfully exited

@awels
Copy link
Member Author

awels commented Oct 1, 2020

Oh i missed you were cloning, so there is a known issue #930 about resizing after cloning. In particular since we can clone any persistent volume, we cannot be sure we cloned a virtual disk. That is why we are not resizing after a clone. It is a definite issue we need to solve at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to resize disk.img to actual DataVolume size
7 participants