Misleading language about image size when creating a new VM

When creating a new (KVM) instance, in the "Disk space allocated to instance" item, the option labeled "Image default (typically 1GB)" is either misleading, or buggy. The wording makes me think that if I select this option the image will be whatever size the image I'm creating from is. But, that's not so. When I select it, and click create, I get this error:

Failed to create system : Disk space must be at least 2 GB, which is the size of the selected image

I'm not sure whether it's intended behavior and just misleadingly labeled, or if it's actually supposed to do what I would think based on reading the option. Looking at the code:

if (!$empty &&
    $img->{'rawsize'} &&
    $img->{'rawsize'} > $server->{'kvm_disksize'}*1024*1024) {
        &error(&text('create_exendisksize2',
                     &nice_size($img->{'rawsize'})));
        }

It seems like $server->{'kvm_disksize"} does not have any opportunity to be populated which it seems like would have to happen to make this code work the way I thought it would. In the below, it's only populated if the user has a plan, or if $in{'kvm_disk_def'} is truthy (it is zero, in my case).

# Validate disk size
if ($plan && $plan->{'max_disk'}) {
        $server->{'kvm_disksize'} = $plan->{'max_disk'} / (1024*1024);
        $server->{'kvm_disktotal'} += $server->{'kvm_disksize'}*1024*1024;
        }
elsif (!$in{'kvm_disk_def'} || $empty) {
        $in{'kvm_disk'} =~ /^\d+$/ || &error($text{'create_exendisksize'});
        $server->{'kvm_disksize'} = ($in{'kvm_disk'} * $in{'kvm_disk_units'}) /
                                    (1024*1024);
        $server->{'kvm_disktotal'} += $server->{'kvm_disksize'}*1024*1024;
        }
else {
        $server->{'kvm_disktotal'} += $img->{'rawsize'};
        }
if (!$empty &&
    $img->{'rawsize'} &&
    $img->{'rawsize'} > $server->{'kvm_disksize'}*1024*1024) {
        &error(&text('create_exendisksize2',
                     &nice_size($img->{'rawsize'})));
        }

So, maybe what's missing is just populating $server->{'kvm_disksize'} when kvm_disk_def is 0?

Status: 
Closed (fixed)

Comments

This looks like a bug - it should by default create the VM disk size to be the same as the image, but clearly that's broken. I'll take a look.

Ok, I've fixed this - it will be included in the next Cloudmin release.

Status: Active » Fixed
Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.