From 5979a7d65ab51fe77c7f3cb55451bbcec30b70b7 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Tue, 27 Aug 2024 17:33:15 +1000 Subject: [PATCH] Take image virtual size into account when creating Volumes This is a followup to https://github.com/harvester/dashboard/pull/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: https://github.com/harvester/harvester/issues/4905 Signed-off-by: Tim Serong --- pkg/harvester/edit/harvesterhci.io.volume.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/harvester/edit/harvesterhci.io.volume.vue b/pkg/harvester/edit/harvesterhci.io.volume.vue index 5c8c41967ee..0d54c5151dc 100644 --- a/pkg/harvester/edit/harvesterhci.io.volume.vue +++ b/pkg/harvester/edit/harvesterhci.io.volume.vue @@ -234,7 +234,14 @@ export default { ...this.value.metadata.annotations, [HCI_ANNOTATIONS.IMAGE_ID]: this.imageId }; - storageClassName = images?.find(image => this.imageId === image.id)?.storageClassName; + 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`; + } + + storageClassName = imageResource?.storageClassName; } else { imageAnnotations = { ...this.value.metadata.annotations }; }