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 Volumes #1113

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

tserong
Copy link

@tserong tserong commented Aug 27, 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

@a110605 a110605 added Bug Fix Something isn't working and removed Bug Fix Something isn't working labels Aug 27, 2024
@tserong tserong marked this pull request as draft August 27, 2024 08:30
@tserong
Copy link
Author

tserong commented Aug 27, 2024

Wait, I've just discovered this isn't quite right -- it's now effectively impossible to manually edit the size once an image is chosen (I think because everything calls update()). I'll have to rework this somehow :-/

votdev
votdev approved these changes Aug 27, 2024
@votdev votdev self-requested a review August 27, 2024 08:40
@tserong tserong force-pushed the wip-add-virtualSize-volume-create branch from 5979a7d to 3ee5fbd Compare August 27, 2024 08:41
@tserong tserong marked this pull request as ready for review August 27, 2024 08:42
@tserong
Copy link
Author

tserong commented Aug 27, 2024

OK, that seems to have done the trick... If there's a better way to structure anything here, please LMK.

@a110605
Copy link
Collaborator

a110605 commented Aug 28, 2024

Sorry, not sure if I misunderstand this PR purpose, we want to pre-fill the Size based on user selected image virtual size or actual size.

Does this PR need specific backend change or master-head is enough ?

It's not work as expected when test locally.

bug.mov

@tserong
Copy link
Author

tserong commented Aug 28, 2024

Sorry, not sure if I misunderstand this PR purpose, we want to pre-fill the Size based on user selected image virtual size or actual size.

Yep, it's meant to pre-fill the Size based on whichever is greater of the image virtual size or actual size.

Does this PR need specific backend change or master-head is enough ?

It should work fine provided your backend harvester cluster is v1.4 or master -- looking at the version in the video, it seems you're on v1.3.1, which doesn't support virtual size... But even in that case I would have expected it to at least fill the field with the physical size of the image -- const imageSize = Math.max(imageResource?.status?.size, imageResource?.status?.virtualSize) should pick up whichever is available, right? -- so I'm not sure what's going on here :-/

@votdev
Copy link
Member

votdev commented Aug 28, 2024

This patch contains some more improvements. You can make use of the already fetched images (see the fetch() method). Don't know why they are fetched because the current code does not make use of it. Maybe @torchiaf should have a final look on it if you want to apply this patch.

diff --git a/pkg/harvester/edit/harvesterhci.io.volume.vue b/pkg/harvester/edit/harvesterhci.io.volume.vue
--- a/pkg/harvester/edit/harvesterhci.io.volume.vue	(revision 3ee5fbdbd0b0d589ebbf7002ceab1ff488846b55)
+++ b/pkg/harvester/edit/harvesterhci.io.volume.vue	(date 1724838170157)
@@ -56,6 +56,7 @@
     const hash = await allHash(_hash);
 
     this.snapshots = hash.snapshots;
+    this.images = hash.images;
 
     const defaultStorage = this.$store.getters[`harvester/all`](STORAGE_CLASS).find( O => O.isDefault);
 
@@ -77,6 +78,7 @@
       storage,
       imageId,
       snapshots: [],
+      images: [],
     };
   },
 
@@ -108,10 +110,8 @@
     },
 
     imageOption() {
-      const choices = this.$store.getters['harvester/all'](HCI.IMAGE);
-
       return sortBy(
-        choices
+        this.images
           .filter(obj => obj.isReady)
           .map((obj) => {
             return {
@@ -251,8 +251,7 @@
     },
     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 imageResource = this.images?.find(image => this.imageId === image.id);
         const imageSize = Math.max(imageResource?.status?.size, imageResource?.status?.virtualSize);
 
         if (imageSize) {

@a110605
Copy link
Collaborator

a110605 commented Aug 28, 2024

Sorry, not sure if I misunderstand this PR purpose, we want to pre-fill the Size based on user selected image virtual size

Test with master-head deployment. It's good. 👍

Just notice the size only accepted integer.... I turn to use formatSi to get more precise size number to decimal.

  this.storage = formatSi(imageSize, {
            increment: 1024, addSuffix: true, maxExponent: 3, minExponent: 3, suffix: 'i'
          });

But got webhook error 😓

Screenshot 2024-08-28 at 11 04 04 PM

@tserong
Copy link
Author

tserong commented Aug 29, 2024

It might be best to just stay with an integer value - I could be wrong, but I don't think we allow decimals anywhere in any size fields, it's all just whole GiB.

@tserong tserong force-pushed the wip-add-virtualSize-volume-create branch from 3ee5fbd to cd9d633 Compare August 29, 2024 02:25
@tserong
Copy link
Author

tserong commented Aug 29, 2024

Thanks @votdev, I've applied that patch and it seems to work fine. I'm happy to wait for @torchiaf to review as well.

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 tserong force-pushed the wip-add-virtualSize-volume-create branch from cd9d633 to 3778552 Compare August 29, 2024 02:30
@a110605 a110605 requested a review from torchiaf August 29, 2024 06:02
@a110605 a110605 added the Enhancement minor or greater UI enhancement label Aug 30, 2024
Copy link
Collaborator

@a110605 a110605 left a comment

Choose a reason for hiding this comment

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

Remember to backport v1.4 after merge.

Copy link
Collaborator

@torchiaf torchiaf left a comment

Choose a reason for hiding this comment

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

LGTM

@tserong tserong merged commit 3f592dd into harvester:master Sep 12, 2024
7 checks passed
@tserong tserong deleted the wip-add-virtualSize-volume-create branch September 12, 2024 07:53
@tserong
Copy link
Author

tserong commented Sep 12, 2024

@Mergifyio backport release-harvester-v1.4

Copy link

mergify bot commented Sep 12, 2024

backport release-harvester-v1.4

✅ Backports have been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement minor or greater UI enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants