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

Take image virtual size into account when creating VMs (backport #976) #1104

Merged

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Aug 16, 2024

Prior to this, the default size for volumes attached to VMs was 10GiB, regardless of the size of the underlying image. This is fine if the image is smaller, but if the image is either physically larger (as in the case of a >10GiB ISO), or has a larger virtual size (as can be true with qcow2 images), the result is a corrupt volume.

This PR fixes the problem by checking both the physical size and virtual size of the image, and using whichever is greater as the default size of the volume. Virtual size should always be >= physical size, but it is still theoretically possible for either value to be zero in case of error, so taking the greater of the two is the safest approach.

There are two exceptions to the above rule:

  1. For non-ISO images, if the image is < 10GiB, we still default to a size of 10GiB for consistency with the behaviour of earlier Harvester releases. The user can always lower this if they want/need to.
  2. ISO images smaller than 1GiB will be given a size of 1GiB, simply because the size control in the UI is set to work in GiB units. It is actually possible to get a value of 0.2 GiB in there for a 200MiB ISO, but doing that is pretty ugly IMO, and there's no real harm in having the volume that backs a CD-ROM image be a bit larger than the source in this case.

This PR also adds Virtual Size as an additional column when listing images. I don't know whether or not this is the best way to present this information. Another alternative could be to make the existing Size column simply report the greater of Size and Virtual Size, on the assumption that what you really care about is the size that a volume needs to be when based on that image.

I've included a couple other small tweaks as well relating to automatically setting disk type and bus for ISO images (see the commit messages for details).

Note that this PR depends on harvester/harvester#5387 which in turn depends on changes in Longhorn.

Related issue: harvester/harvester#5142
Related issue: harvester/harvester#4905
Related issue: harvester/harvester#2189


This is an automatic backport of pull request #976 done by Mergify.

The onImageChange() function in
edit/kubevirt.io.virtualmachine/VirtualMachineVolume/type/vmImage.vue
includes logic to set type="cd-rom" and bus="sata" when you select an
ISO image as the source for a volume.  This commit applies the same
logic when initially creating a VM from a given image.

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit db0a588)
The onImageChange() function sets the VM volume type="cd-rom" and
bus="sata" when an ISO image is selected, but it only works for
the first volume.  This commit enables the automatic type and bus
selection for all volumes attached to a VM.

Related issue: harvester/harvester#5142

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 90e6535)
Prior to this, the default size for volumes attached to VMs was 10GiB,
regardless of the size of the underlying image.  This is fine if the
image is smaller, but if the image is either physically larger (as in
the case of a >10GiB ISO), or has a larger virtual size (as can be true
with qcow2 images), the result is a corrupt volume.

This commit fixes the problem by checking both the physical size and
virtual size of the image, and using whichever is greater as the default
size of the volume.  Virtual size should always be >= physical size, but
it is still theoretically possible for either value to be zero in case
of error, so taking the greater of the two is the safest approach.

There are two exceptions to the above rule:

1) For non-ISO images, if the image is < 10GiB, we still default to a
   size of 10GiB for consistency with the behaviour of earlier Harvester
   releases.  The user can always lower this if they want/need to.

2) ISO images smaller than 1GiB will be given a size of 1GiB, simply
   because the size control in the UI is set to work in GiB units.  It is
   actually possible to get a value of 0.2 GiB in there for a 200MiB ISO,
   but doing that is pretty ugly IMO, and there's no real harm in having
   the volume that backs a CD-ROM image be a bit larger than the source
   in this case.

Related issue: harvester/harvester#4905
Related issue: harvester/harvester#2189

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit ec15f49)
This commit adds Virtual Size as an additional column when listing
images.  I don't know whether or not this is the best way to present
this information.  Another alternative could be to make the existing
Size column simply report the greater of Size and Virtual Size, on
the assumption that what you really care about is the size that a
volume needs to be when based on that image.

I've also added Virtual Size to the Image Detail page.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit a0cc74c)
@a110605 a110605 merged commit 444363a into release-harvester-v1.4 Aug 16, 2024
5 checks passed
@mergify mergify bot deleted the mergify/bp/release-harvester-v1.4/pr-976 branch August 16, 2024 03:44
tserong added a commit to tserong/dashboard that referenced this pull request Aug 27, 2024
This is a followup to harvester#1104

When creating new volumes from VM images on the Volume screen,
the default size is empty, i.e. it's not pre-filled with anything
at all.  If the source is set to "VM image" we can now take the
image virtual size and use that as the default size for the
volume.  Unlike when creating VMs (which always set the volume
to a minimum of 10GiB regardless of virtual size, for consistency
with earlier harvester versions), on this screen we just use the
virtual size as-is.  If the user wants to make it bigger, they
can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
tserong added a commit to tserong/dashboard that referenced this pull request Aug 27, 2024
This is a followup to harvester#1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
tserong added a commit to tserong/dashboard that referenced this pull request Aug 27, 2024
This is a followup to harvester#1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
tserong added a commit to tserong/dashboard that referenced this pull request Aug 29, 2024
This is a followup to harvester#1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
Co-authored-by: Volker Theile <vtheile@suse.com>
tserong added a commit to tserong/dashboard that referenced this pull request Aug 29, 2024
This is a followup to harvester#1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
Co-authored-by: Volker Theile <vtheile@suse.com>
mergify bot pushed a commit that referenced this pull request Sep 12, 2024
This is a followup to #1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
Co-authored-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 3778552)
a110605 pushed a commit that referenced this pull request Sep 16, 2024
This is a followup to #1104

When creating new volumes on the Volume screen in Harvester, the
default size is empty, i.e. it's not pre-filled with anything at
all.  If the source is set to "VM image" we can now take the image
virtual size and use that as the default size for the volume.
Unlike when creating VMs (which always set the volume to a minimum
of 10GiB regardless of virtual size, for consistency with earlier
harvester versions), on this screen we just use the virtual size
as-is.  If the user wants to make it bigger, they can.

Related issue: harvester/harvester#4905

Signed-off-by: Tim Serong <tserong@suse.com>
Co-authored-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 3778552)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants