[GH-ISSUE #17] Error on Resize #15

Closed
opened 2026-02-26 17:32:06 +03:00 by kerem · 15 comments
Owner

Originally created by @Nevercold on GitHub (Dec 4, 2021).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/17

Hey,

I have some problems with resizing a hard disk.

e.g.
$disk = 10;
$host_name = "server01"; (ServerName)
$service_id = "100"; (VM ID)

$request = $proxmox->getNodes()->get($host_name)->getQemu()->get($service_id)->getResize()->resizeVm("scsi0", "+".$disk ."G");
Resizing does not work with the shown command, the error message just says "null". everything else works, with the same data.

I also get this error (sometimes).

"TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php:156",
"Stack trace:",
"#0 \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php(156): array_key_exists()",
"#1 \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php(166): Corsinvest\\ProxmoxVE\\Api\\Result->responseInError()",
"#2 proxmoxController.php(161): Corsinvest\\ProxmoxVE\\Api\\Result->getError()",
"#3 ..."

161 = if(!$request->isSuccessStatusCode()) return ...

Please help.

Originally created by @Nevercold on GitHub (Dec 4, 2021). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/17 Hey, I have some problems with resizing a hard disk. e.g. $disk = 10; $host_name = "server01"; (ServerName) $service_id = "100"; (VM ID) `$request = $proxmox->getNodes()->get($host_name)->getQemu()->get($service_id)->getResize()->resizeVm("scsi0", "+".$disk ."G");` Resizing does not work with the shown command, the error message just says "null". everything else works, with the same data. I also get this error (sometimes). ``` "TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php:156", "Stack trace:", "#0 \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php(156): array_key_exists()", "#1 \/vendor\/corsinvest\/cv4pve-api-php\/src\/Result.php(166): Corsinvest\\ProxmoxVE\\Api\\Result->responseInError()", "#2 proxmoxController.php(161): Corsinvest\\ProxmoxVE\\Api\\Result->getError()", "#3 ..." ``` 161 = `if(!$request->isSuccessStatusCode()) return ...` Please help.
kerem 2026-02-26 17:32:06 +03:00
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

Hi,
I check the problem and update you.

Best regards

<!-- gh-comment-id:986555552 --> @franklupo commented on GitHub (Dec 6, 2021): Hi, I check the problem and update you. Best regards
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

I've tested a bit, the error occurs after the VM is created or cloned. Adjust the configuration is still possible.

The error does not occur if I do it afterwards. Strange.

<!-- gh-comment-id:986628877 --> @Nevercold commented on GitHub (Dec 6, 2021): I've tested a bit, the error occurs after the VM is created or cloned. Adjust the configuration is still possible. The error does not occur if I do it afterwards. Strange.
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

Ok,
from web interface work correctly?

<!-- gh-comment-id:986633112 --> @franklupo commented on GitHub (Dec 6, 2021): Ok, from web interface work correctly?
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

yea.

<!-- gh-comment-id:986636133 --> @Nevercold commented on GitHub (Dec 6, 2021): yea.
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

yea.

???

<!-- gh-comment-id:986655227 --> @franklupo commented on GitHub (Dec 6, 2021): > yea. ???
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

Everything works perfectly from the web interface (pve-7.1)

<!-- gh-comment-id:986712555 --> @Nevercold commented on GitHub (Dec 6, 2021): Everything works perfectly from the web interface (pve-7.1)
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

Ok,
You can reporduce erorr from api?

<!-- gh-comment-id:986818710 --> @franklupo commented on GitHub (Dec 6, 2021): Ok, You can reporduce erorr from api?
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

Ok, You can reporduce erorr from api?
What do you mean?

=> VM is cloned (task finished)

$clone = $proxmox->getNodes()->get($host_name)->getQemu()->get($template_id)->getClone()->cloneVm(
      (int) $service_id,
      full: true,
      name: $subdomain
);
$task = $clone->getResponse()['data'];
$task = $this->checkTask($task, $proxmox, $host_name, 5, 25); // Checks task every 5 sec until it finishes to see if it was successful.
if(!$task['success']) return $task;

=> VM disk is resized (error)

$disk = $disk."G";
sleep(5);
$request = $proxmox->getNodes()->get($host_name)->getQemu()->get($service_id)->getResize()->resizeVm("scsi0", $disk);
    
if(!$request->isSuccessStatusCode()) return array("success" => false, "error" => $request->getResponse(), "status_code" => $request->getStatusCode());

If I would do updateVmAsync() before resize, that would work too, only resize doesn't work.

<!-- gh-comment-id:986861745 --> @Nevercold commented on GitHub (Dec 6, 2021): > Ok, You can reporduce erorr from api? What do you mean? => VM is cloned (task finished) ``` $clone = $proxmox->getNodes()->get($host_name)->getQemu()->get($template_id)->getClone()->cloneVm( (int) $service_id, full: true, name: $subdomain ); $task = $clone->getResponse()['data']; $task = $this->checkTask($task, $proxmox, $host_name, 5, 25); // Checks task every 5 sec until it finishes to see if it was successful. if(!$task['success']) return $task; ``` => VM disk is resized (error) ``` $disk = $disk."G"; sleep(5); $request = $proxmox->getNodes()->get($host_name)->getQemu()->get($service_id)->getResize()->resizeVm("scsi0", $disk); if(!$request->isSuccessStatusCode()) return array("success" => false, "error" => $request->getResponse(), "status_code" => $request->getStatusCode()); ``` If I would do updateVmAsync() before resize, that would work too, only resize doesn't work.
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

The same step in web Gui work correctly?

Best reagards

<!-- gh-comment-id:986877004 --> @franklupo commented on GitHub (Dec 6, 2021): The same step in web Gui work correctly? Best reagards
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

Strange. Yesterday I tried it, everything went perfectly via the web interface...

Today I try it, comes a timeout error. So apparently Proxmox needs time after the clone.
Running Resize again then worked. Facepalm.

command '/usr/bin/qemu-img resize -f qcow2 /var/lib/vz/images/1004/vm-1004-disk-0.qcow2 3221225472' failed: got timeout (500)

<!-- gh-comment-id:986882168 --> @Nevercold commented on GitHub (Dec 6, 2021): Strange. Yesterday I tried it, everything went perfectly via the web interface... Today I try it, comes a timeout error. So apparently Proxmox needs time after the clone. Running Resize again then worked. Facepalm. command '/usr/bin/qemu-img resize -f qcow2 /var/lib/vz/images/1004/vm-1004-disk-0.qcow2 3221225472' failed: got timeout (500)
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

I'm adding a longer sleep in a moment, and testing again.

<!-- gh-comment-id:986883604 --> @Nevercold commented on GitHub (Dec 6, 2021): I'm adding a longer sleep in a moment, and testing again.
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

Thank you so much you are doing a great job improving this library

<!-- gh-comment-id:986897591 --> @franklupo commented on GitHub (Dec 6, 2021): Thank you so much you are doing a great job improving this library
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

Error found. With a sleep of 20 seconds it works.

<!-- gh-comment-id:987040687 --> @Nevercold commented on GitHub (Dec 6, 2021): Error found. With a sleep of 20 seconds it works.
Author
Owner

@franklupo commented on GitHub (Dec 6, 2021):

I have updated the library. Can you test if ok?

Bets regards

<!-- gh-comment-id:987043262 --> @franklupo commented on GitHub (Dec 6, 2021): I have updated the library. Can you test if ok? Bets regards
Author
Owner

@Nevercold commented on GitHub (Dec 6, 2021):

Have already updated, it seems that everything works

<!-- gh-comment-id:987044716 --> @Nevercold commented on GitHub (Dec 6, 2021): Have already updated, it seems that everything works
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-php#15
No description provided.