proxmoxer/proxmoxer

returning invalid task ID from VM start command

vakabus opened this issue · 5 comments

Hi, I've found a weird behavior which I am assuming is a bug. I am not sure if it's related to the library or Proxmox API itself, I am posting it just here for now.

What happens

When I run:

from proxmoxer import ProxmoxAPI
proxmox = ProxmoxAPI("tapir.lan", user="root", backend="openssh", service="pve")
proxmox.nodes("tapir").qemu(500).status.start.post()

the return value of the last command is:

{'errors': b'generating cloud-init ISO\n"UPID:tapir:00128784:028D7FB7:6363E6E9:qmstart:500:root@pam:"'}

What I would expect

I would expect just the string UPID:tapir:00128784:028D7FB7:6363E6E9:qmstart:500:root@pam: being returned.

I'm 99% sure this is an issue with PVE, but just to check can you try the same thing with the https backend? This might be an issue where the CLI for the API (which is what the openssh backend uses) prints extra information when using cloud-init.

I can confirm that with the https backend it works as expected and only the task id is returned.

yeah, than this is a Proxmox issue. You can ask about the issue on the official forums or just directly file a PVE bug

This issue also occurs in local mode (which is more or less SSH backend without the SSH).

I guess Proxmox shouldn't return an informative message as an error, so it really is a Proxmox issue, but the VM does actually start without any issues as far as I can tell, so of course, that's confusing.

For reference, I see that this has been reported to Proxmox : https://bugzilla.proxmox.com/show_bug.cgi?id=4333

Seems to be messages are being output to STDOUT rather than STDERR or added to the JSON properly.

I guess Proxmox shouldn't return an informative message as an error

To be clear, Proxmox outputs the message to STDOUT, which leads to Proxmoxer trying to parse both the message line and the following JSON line as JSON.

While this is of course a Proxmox issue, and has already reported, it would still make sense in my opinion to work around it in Proxmoxer until an official fix has been released, since as least Proxmox 7.2 and 7.3 are affected by this now.

As far as I can tell, it should be as simple as trying parsing only the last line as JSON if parsing fails the first time on the affected Proxmox versions. Basically what I did at https://github.com/ansible-collections/community.general/pull/4027/files#diff-e0436e452ddd5c8a44426d18198373fd4f991b98348e497741e111495defaf47R1023-R1025, but more generally applied to all Proxmoxer calls.