Skip to content

Commit

Permalink
Take image virtual size into account when creating Volumes
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tserong committed Aug 27, 2024
1 parent b97bf06 commit 3ee5fbd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/harvester/edit/harvesterhci.io.volume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,18 @@ export default {
this.$set(this.value, 'spec', spec);
},
updateImage() {
if (this.isVMImage && this.imageId) {
const images = this.$store.getters['harvester/all'](HCI.IMAGE);
const imageResource = images?.find(image => this.imageId === image.id);
const imageSize = Math.max(imageResource?.status?.size, imageResource?.status?.virtualSize);
if (imageSize) {
this.storage = `${ Math.ceil(imageSize / 1024 / 1024 / 1024) }Gi`;
}
}
this.update();
},
generateYaml() {
const out = saferDump(this.value);
Expand Down Expand Up @@ -300,7 +311,7 @@ export default {
required
:mode="mode"
class="mb-20"
@input="update"
@input="updateImage"
/>
<LabeledSelect
Expand Down

0 comments on commit 3ee5fbd

Please sign in to comment.