Resize API endpoint (PUT) - async?

muhaha

New Member
May 17, 2018
8
1
1
35
Hello,
I am creating VMs (qemu) in Proxmox with Ansible.
1. Clone(API endpoint - POST) -> cloud-init template
2. Config(API endpoint - POST) -> cloned VM
3. Resize(API endpoint - PUT) -> scsc0 -> size=+10G


Clone request will return task ID in response, so I can check if VM was cloned to continue.
Config will not return anything usefull, but It will always success.
Resize will sometimes return /usr/bin/qemu-img resize -f raw /data/pool1/images/101/vm-101-disk-0.raw 10737418240' failed: got timeout and it does not matter if I am using size=+1G, size=10G, size=+10G.


I am assuming that VM is not ready for Resize yet, but I am not sure, how can I check it to run another step (Resize)

If I create request /let say 5min after VM config/ it will always return success. So there is some kind of background task which will need to be completed to Resize disk.

Any ideas?
 
we should probably change resize_vm to be async and fork a worker. could you file an enhancement request at https://bugzilla.proxmox.com ?
 
hello,

I encountered the same problem to deploy via terraform. The timeout of the qemu-img resize command is 10s and impossible to overload. So I made a local patch to volume_resize function.

Perl:
sub volume_resize {
    my ($class, $scfg, $storeid, $volname, $size, $running) = @_;

    die "can't resize this image format\n" if $volname !~ m/\.(raw|qcow2)$/;

    return 1 if $running;

    my $path = $class->filesystem_path($scfg, $volname);

    my $format = ($class->parse_volname($volname))[6];

    my $cmd = ['/usr/bin/qemu-img', 'resize', '-f', $format, $path , $size];

    run_command($cmd, timeout => 10);

    return undef;
}


Cf => https://github.com/proxmox/pve-storage/blob/master/PVE/Storage/Plugin.pm#L668-L684



It would be great to overload the timeout from the API.
 
  • Like
Reactions: morph027
Hi,

I stumbled across this problem too.

My "workaround" was to wait for the iowait value to go below 2 (top -d2 -bn1 | grep -o -E '[[:digit:]]+.[[:digit:]]+ wa,' | sed 's/ wa,//') before trying to resize the disk so that the qemu-img command last less than 10 seconds.

Any news on https://bugzilla.proxmox.com/show_bug.cgi?id=2315 ?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!